is there any "OnError" method in sikuli?

Asked by Martin J

is there any "On Error"-handler or some function which acts like this?

for example i use the following script:
if exists(img):
>>>hover(img)
>>>click(img)
else:
something else

my problem is, that the image is there, but disapears from time to time so the script fails in these cases.
how can i make the script continue on those errors?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

recommended:
--- the extra hover() is not needed
--- click(getLastMatch)) avoids additional find operation (faster!)

if exists(img):
    click(getLastMatch()) # clicks the already found image
else:
    something else

Since we are talking Python: mind indentation/dedentation (tab/shift-tab)

faq 1501 and faq 1607 might be helpful.

Can you help with this problem?

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

To post a message you must log in.