while exists (img,0) always stop loop

Asked by alex on 2017-06-24

while exists ("1498312677594.png"):
      if exists (Pattern("1498307427007.png").exact(),0):
          print "Found Deniro*"
          #locationMap
          hover(Location(1140,110))
          click(hover)
          #battleicon
          doubleClick("1498310619746.png")
          click(Pattern("1498310847322.png").similar(0.90))
          wait(30)
          #battleicon
          doubleClick("1498310619746.png")
          click(Pattern("1498310803864.png").similar(0.90))
          #locationMap
          hover(Location(1140,110))
          click(hover)

 the problem here is..when dont find click(Pattern("1498310847322.png").similar(0.90)) it just break the loop

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-06-24
Last reply:
2017-06-25
masuo (masuo-ohara) said : #1

What do you want to do when 1498310847322.png is not found?

alex (alexdniel88) said : #2

@masuo
thanks for ur kindness respond..what i want is..when is not found..
i want the sikuli search again that "1498310847322.png"
is it possible?

masuo (masuo-ohara) said : #3

If image dose not exist when using click() and find() and wait(), FindFailed exception occurs.
http://sikulix-2014.readthedocs.io/en/latest/region.html?highlight=FindFailed

How to continue SikuliX process even if FindFailed exception will occur.

[sample codes]
while True:
    try:
        wait("1498310847322.png",0)
        print "Appeared"
        break
    except FindFailed:
        print "FindFailed"
        sleep(1)

A way to use exists() that dose not raise FindFailed exception.

[sample codes]
while True:
    if not exists("1498310847322.png",0):
        Do.popup("waiting",1)
    else:
        click()
        break

Can you help with this problem?

Provide an answer of your own, or ask alex for more information if necessary.

To post a message you must log in.