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

11.6k Views Asked by At

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.

2

There are 2 best solutions below

1
On

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

0
On

The wait(pattern, 3600) is equivalent to wait(pattern, FOREVER) which is described here and will wait for the pattern indefinitely. In case like yours, the only thing that can explain this behavior is if the pattern was actually found on the screen and the below line confirms that:

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]

Perhaps this pattern appears elsewhere and you missed it? Or maybe the similarity parameter is too low and another pattern gets recognized. To check that try to use the highlight(1) method.

ptrn = find("pattern.png")
ptrn.highlight(1)

This might shed some light.