looping problem

Asked by milin agrawal

i have made one script,in this after filling all d required fields when i click on "Submit Request" button,then a message comes like the request is already exists,do u stiill want to submit?
so i want looping for it,means when it doesnt come that time also i want to submit it and when it comes that time also.

click (img1)
while find( "img1" )
click(img )
while not find ( "img1" )
wait (5)
click (img2)

plz suggest me the appropriate code in python

Question information

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

have a look at: faq 1437

Revision history for this message
milin agrawal (milin) said :
#2

click (img1)
while find( "img1" )
click(img )
while not find ( "img1" )
wait (5)
click (img2)

plz suggest me the appropriate code in python

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

it seems you have not read faq 1437 (indentation missing) - but anyway

This is valid Python code:

click (img1)
while find( "img1" ):
   click(img )
while not find ( "img1" ):
   wait (5)
click (img2)

But Sikuli script ???

find() in if/elif/while does not make sense, since if not found the script will stop anyway
(see docs http://sikuli.org/docx/region.html#exception-findfailed)

If img1 is not found, the script will stop anyway with the 1st click()

the intention of:

while not find ( "img1" ):
   wait (5)
click (img2)

is ok, but would never work (see above):

while not exists( "img1" ): # will wait until img1 comes up
   wait (5)
click (img2)

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

might help others
FAQ #1437: “How to repeat something in a Sikuli script (make loops)”.

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