Sikuli IDE command wait("image") not waiting for image to appear before script continues

Sunil Kumar picture Sunil Kumar · Dec 19, 2017 · Viewed 7.8k times · Source

I am new to Sikuli and am trying it out with a very simple script that looks like this...

wait and click cmds are used and they are working, The issue i am facing is wait("1513068228396.png",3600) is not waiting until image appears,, it waits for some 10 to 15 secs and executes next cmd. I tried including some Logs, and also tried with other images to same wait cmd, still same result.

wait("1513067960826.png",60)
click(Pattern("1513066493827.png").targetOffset(-106,2))
sleep(2)
click("1513066637741.png")
sleep(1)
click("1513599247108.png")
sleep(5)
print "wait for my image"

wait("1513068228396.png",3600)  # Facing issue in this line

print "found my image"

outputLog :

wait for my image
[debug] Region: find: waiting 3600.0 secs for 1513068228396.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: 1513068228396.png (file:/D:/softwares/sikuli/SENINFO_V100R002C00SPC700.sikuli/1513068228396.png)
[debug] Region: checkLastSeen: not there
[debug] Region: find: 1513068228396.png has appeared at M[832,379 30x16]@S(S(0)[0,0 1920x1080]) S:0.70 C:847,387 [753 msec]
found my image

Any suggestion how to solve this issue.

Answer

Michael Becerra picture Michael Becerra · Dec 19, 2017

Maybe that image have a similarity with some region in the screen. You could try to set the similarity to the highest value:

wait(Pattern("some_image.png").similar(0.8),) # if you want the 80% of similarity
wait(Pattern("some_image.png").exact()) # if you want the 100% of similarity

Also, I encourage you to use if exists instead of wait. Wait will end the program if the image doesn't exist:

if exists(Pattern("some_image.png").exact(),3600):
    click("some_image.png")

You can find Pattern documentation here