implicit wait in Sikuli

Asked by Sathyamoorthy

Hi,

I have written sikuli script for my taks. In that i have called wait() function to get a proper image. Since application some times take less time to proceed further , or some times takes more time to proceed further. Since i have given wait time.

Now i need a solution for, if the required image is found with in wait time , then script should wait until the wait time gets complete. script should go further.

So how to do that . Please guide me

Thanks in Advance,
V.Sathyamoorthy

Question information

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

maxWait = 50 # seconds
start = time.time()
wait(some_image, maxWait)
imageWait = time.time()-start
if imageWait < maxWait: wait(maxWait - imageWait)

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#2

Could you please give me explanation ... I could not understand

Revision history for this message
nupur (nupur) said :
#3

@Sathyamoorthy:

U can use wait(some-image, max-wait)
It will wait for an image for upto the given time, if the image appears before the given time, it will proceed futher.

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#4

Thanks for the information. Let me try out it

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

@ nupur

that is what I do in my suggestion (line 3 ;-)
But if the image comes up earlier, the script will continue with your suggestion.

He wants to wait for the image, but also wait maxTime if the image is found earlier.

@Sathyamoorthy:
For someone who seems to script complex workflows, the snippet in comment #1 should be self explaining ;-)

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#6

@RaiMan: Thanks Man.
I am just started playing with Sikuli and python. That is reason i am expecting detailed explanation. Thanks for your help and support

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#7

Hi
wait(some_image, maxWait) will wait until image is found. if image is found then it will proceed to next step.

What about
imageWait = time.time()-start
if imageWait < maxWait: wait(maxWait - imageWait)

why we need to wait for Max time, if image is found? is there any thing specific?

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

--- if the required image is found with in wait time , then script should wait until the wait time gets complete.
this is what you asked - may be I missunderstood:
- You want to wait for the image for maxTime
- if image is found within maxTime (means earlier),
- the script should wait until total maxTime exceeds

What about
imageWait = time.time()-start # time before find starts
if imageWait < maxWait: # time to find shorter than maxWait
    wait(maxWait - imageWait) # if yes, wait the rest of time until maxWait exceeded

--- wait(some_image, maxWait) will wait until image is found. if image is found then it will proceed to next step.
yes, correct.
If this is what you need only: forget my suggestion and be happy ;-)

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#9

Hey Thanks Dude.
Closing this query