Maximum time limit for executing Repeat Until Command

How to set the maximum time limit for Repeat Until imagefound ("X") Command ?[/b]

Comments

  • You can specify a maximum image search time with the ImageFound() function like this:
    Repeat until ImageFound(10,"MyImage")
    
    If you do this, keep in mind that this repeat loop will execute infinitely unless given an exit. The maximum wait time of 10 seconds in the ImageFound() function only applies to the image search.

    If you also want a maximum time for the entire repeat loop, you need to set the time before the repeat loop. If you set it in the repeat loop declaration itself, and you're not using a hard-set time, then it will be re-set each time through, and the repeat loop will not end. Here is an example:
    Set endTime to 3 minutes hence
    repeat until imagefound("myimage") or the time is later than endTime
    //do something
    end repeat
    
    Or you can set a specific time:
    set endTime to asTime("07:51")
    repeat until imagefound("myimage") or the time is later than endTime
    //do something
    end repeat
    
    You can read about hence here: http://docs.testplant.com/?q=date-operators
    You can read about time and date functions, including the asTime() function, here: http://docs.testplant.com/?q=content/working-dates-and-times

    You can also always use the RepeatIndex to determine how many times the loop has repeated, and exit based on the number of iterations. Read about the RepeatIndex here: http://docs.testplant.com/?q=repeat-loops#the-repeatindex
  • Thank You Elizabeth
    Have a good time ahead.
Sign In or Register to comment.