If Statement isn't working for me

Asked by Koby Wong

Hi, I looked through the other questions asked and answered and didn't see my exact problem, so here it goes.

if find():
   click()
else:
   pass

Whenever the picture in find() isn't found, the script stops working and doesn't go to the else step. Any help is greatly appreciated!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Koby Wong
Solved:
Last query:
Last reply:
Revision history for this message
Koby Wong (kobywong09) said :
#1

Ah, didn't realize I needed this piece of code at the beginning.

setThrowException(False)

Thanks for looking at this!

Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#2

Or you can use exists(), which doesn't throw out an exception, instead of find().

Revision history for this message
Koby Wong (kobywong09) said :
#3

Sweet, nice to know about the alternative exists(). Thanks for your response.