Drag and drop while IF is untrue?

Asked by arminius

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

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
arminius
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
masuo (masuo-ohara) said :
#1

try following codes.

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

    else:
        mouseMove(SCREEN.getCenter())
        # add drag and drop operation

    sleep(3) # to aboid CPU load

Revision history for this message
arminius (arminius75) said :
#2

Thanks I'll try that when I get home.

Revision history for this message
arminius (arminius75) said :
#3

Worked great, thanks.

Revision history for this message
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'", )"

Revision history for this message
arminius (arminius75) said :
#5

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