Problem regarding wait(pattern)

Asked by Matthew Eaton

Hi guys,

I'm using Sikuli 1.0.1 to automate running some tests. Here is what I'm doing in pseudo code:

open app
click(button) # starts the test
wait(button), FOREVER # wait for the button to return to its original state (test complete)
continue script

The problem with the above is sometimes Sikuli finds a match with "wait(button), FOREVER" before the test is complete. This happens intermittently so I think the button is returning to it's original state for a split second mid-test and sometimes Sikuli picks up on this and returns a match.

Is there any way to tell Sikuli not to return a match until the pattern has been seen for X amount of time? Or any other workaround?

Question information

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

You should use a construct using exists() instead of wait(), soyou have more options:

while True: # means forever
    if (exists(button,0)):
        wait(0.5) # you decide how long
        if (exists(button, 0):
            break # button is stable
    wait(1) # and check again

Revision history for this message
Matthew Eaton (meaton) said :
#2

Thanks RaiMan, I can't test until next week but that looks like it will work. Marking as solved.

Revision history for this message
Matthew Eaton (meaton) said :
#3

Thanks RaiMan, that solved my question.