wait command

Asked by janani pavithra

Hi RaiMan,
click("image1")
wait(10)
click("image2")

This will make Sikuli script to wait for 10 seconds after clicking image1 and then it clicks image2....

Now i wanted to know that, Is there any command tat makes the 'click' as soon as the image pop up?
like
click("image1")
click the image2 as soon as the image2 pops up..(without any 'wait')

Regards,
Janani Pavithra

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

2 choices: wait(image, timeout) (aborts script if not found after max waiting time with exception FindFailed) and exists(image, timeout) (same as wait, but no FindFailed exception, returns None if not found (best use together with if ).

with wait() storing the match:
click("image1")
m = wait("image2", 10) # save match in variable m
click(m)

with wait() using getLastMatch():
click("image1")
wait("image2", 10) # stores the match internally
click(getLastMatch()) # clicks on the match of last successful find operation, in this case the wait()

with exists() using getLastMatch() (my preferred version):
click("image1")
if exists("image2", 10):
   click(getLastMatch())
else:
   popup("Sorry, not found")
   exit()

Using exists() allows to program alternatives on how to proceed in the workflow.

Revision history for this message
Shiva Golchi (shiva-golchi) said :
#2

Is there any way to set this timeout as a global setting to apply to all exists() s?
e.g. I have a code with a lot of assert exists(image) s for a UI; however my application can be laggy sometimes and on every run it can take a random time for the images to show up. So I get random assertion errors every time I run the script on random images.
I have been using setAutoWaitTimeout () as a global setting but seems not to be working on assertions.

Revision history for this message
muhin (muhin-aiict) said :
#3

wait(10) is not working in java. Is there any alternate solution to wait in Java? I got this error
 Exception in thread "main" java.lang.IllegalMonitorStateException
 at java.lang.Object.wait(Native Method)
 at com.sikuli.my.practice.sikuliRunner.runSikuli(sikuliRunner.java:13)
 at com.sikuli.my.practice.SikuliPracticing.main(SikuliPracticing.java:18)

I don't want to use wait("image.png", 10)

Revision history for this message
RaiMan (raimund-hocke) said :
#4

@muhin
must be
wait(10.0) or
wait(10f)

Revision history for this message
muhin (muhin-aiict) said :
#5

Thanks RaiMan

Can you help with this problem?

Provide an answer of your own, or ask janani pavithra for more information if necessary.

To post a message you must log in.