Drag and drop while IF is untrue?

Asked by arminius on 2017-06-13

I am testing a website out, and there's a large drag and drop that keeps coming close to where I want it, but it's a bit random.
Is it possible to screenshot exactly what I want the output to be, and then create an IF statement that is along the lines of.
For example.
LINE 9 "find("1497326478425.png")" IF found then move to LINE 27, IF NOT found move to LINE 10.
LINE 10 "mouseMove(SCREEN.getCenter())" and drag and drop X-1, Return to LINE 9.

So if the above worked it would just keep repeating for ever until it eventually found the screenshot I'm after, upto me to design it to find it in seconds and not hours.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:

This question was reopened

masuo (masuo-ohara) said : #1

try following codes.

while True:
    if exists("1497326478425.png"):

        # add drag and drop operation

    sleep(3) # to aboid CPU load

arminius (arminius75) said : #2

Thanks I'll try that when I get home.

arminius (arminius75) said : #3

Worked great, thanks.

arminius (arminius75) said : #4

actually I spoke to soon, I didn't fully run the entire code, I was looking for the drag and drop operation.
now it's returning with "[error] SyntaxError ( "no viable alternative at input 'sleep'", )"

arminius (arminius75) said : #5

sorry, I had to log out and back in and when I tried again it worked fine.