sikuli script with looping

Asked by milin agrawal

... some code

click( )
while find( " " )
click( )
while not find( " " )
wait(3)
click( )

... some more code

this is a script but it is not running
plz reply soon

Question information

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

--1. It is bad habit, to post another similar question and leave the other one open (https://answers.launchpad.net/sikuli/+question/147333).

--2. it seems you did not follow the posted suggestions nor look at FAQ 1437 or http://sikuli.org/docx/region.html#exception-findfailed (indentations missing, still using "while find()" and "while not find()")

--3. as you might realize yourself, it does not make sense, to simply post a script without any explanations. You might put the .html of your script somewhere in the net and post a link to it. Putting some comments in between could help others to understand.

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

see what i am exactly doing is i am just filling some information to create a request and after filling this information when i click on "submit request" button,that time if this request is already exists the pop up comes and then again i have to click on submit request button,for this i have made the script but when the request is new and pop up doesn't come that time it is not working, using if loop also,i use

if find(img)
but when it is not finding the image,it stops.
so plz suggest me the proper code

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

all is said - just read.

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

i am really not getting what i suppose to do from that doc also plz provide me some coding 4 it

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

your code again:

click( )
while exists( " " )
   click( )
while not exists( " " )
   wait(3)
click( )

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

SyntaxError: ("no viable alternative at input 'Listofsimila'", ('C:\\Users\\agrmilin\\AppData\\Local\\Temp\\sikuli-tmp6144253906013789612.py', 35, 16, 'while exists( ""Listofsimila-2.png"" )\n'))

this error is coming after doing this

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

You should learn some Python to get independent ;-)

this was an easy one: the colons are missing

click( )
while exists( " " ):
   click( )
while not exists( " " ):
   wait(3)
click( )

... I could say this was a test for you --- but I don't: Sorry, my fault :-(

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

SyntaxError: ("no viable alternative at input 'Listofsimila'", ('C:\\Users\\agrmilin\\AppData\\Local\\Temp\\sikuli-tmp7938458638690439630.py', 34, 16, 'while exists( ""Listofsimila-2.png"" ):\n'))

still it is coming

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

There seem to be double "" in the exists( ""Listofsimila-2.png"" ) ????

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

while exists( "list of similar request" ):
 click(scroll bar)
        click(submit request)
while not exists( "list of similar request" ):
 wait(3)
click(add journal)

this is my exact code

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

Using Sikuli X-1.0rc2?

seems to be an indentation problem.

while exists( "list of similar request" ): # you are searching for the text <list of similar request>
 click(scroll bar)
 click(submit request)
while not exists( "list of similar request" ):
 wait(3)
click(add journal)

the indentation within a block (if/elif/else/while/for/with/) have to be exactly the same.
Recommendation with Sikuli: use 1 tab per level (never use blanks!), since tabbing is supported by the Edit menu and will be supported with some automatic indent/dedent in the next version.

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

i deleted the while not exist statement and add break command and it is done
thanx a lot

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

Thanks RaiMan, that solved my question.