How to Set Up a Basic Loop

Asked by Moneer

Hello,

I am trying to set up a basic script that will click on a group of icons and do some tasks. I have a page with a list of maps (3 columns, with about 20 maps in each column), each building map has the same button next to it. When you double-click that button, a new page opens that has a map of that building. I would like my script to double-click the icon, print the map to PDF, then go back to the main page and do the same for all the other maps.

I was able to get Sikuli to perform the task for 1 map. In other words, I got it to locate the button, click it, print the map to PDF, and then go back to the main page. However, when I try to set up a loop, it does not work as expected. What is the best way to set up the loop. I have the following:

for x in findAll("1447248227901.png"):
    doubleClick(x)
    wait(5)
    p = find("1447248404826.png")
    click(p)
    c = find("1447248767352.png")
    click(c)
    b = find("1447248503976.png")
    click(b)

When I run the script, here is what happens:
The first button is located (correctly) and double-clicked
The maps loads
The script waits 5 seconds (correctly)
clicks p and c are performed (correctly)
click b is performed and the main page loads again (correctly)
INSTEAD of the second button being located (i.e. the next x in my findall command), instead the script looks for p and performs click(p), which is not the desired behavior.

So basically, how do I get it to locate the next button (or next x in my findall) and loop through these commands again?

Any help is greatly appreciated!

Thanks,

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

try adding an additional wait just before your:

 doubleClick(x)

It looks that at the moment thsi double click happens immediately after click(b) which might be the cause of your problem.

Can you help with this problem?

Provide an answer of your own, or ask Moneer for more information if necessary.

To post a message you must log in.