how to use FindAll in a loop

Asked by Sander

Hi!

findAll function is really nice, however I want to use it a bit of a different purpose.
I am trying to findAll checkboxes on screen, but only click a few of them.

I understand that the findAll function will return all locations of the images found

count = 0
findAll("checkbox")
for x in findAll("checkbox"):
    while count < 5:
        click(x)
        count = count +1

It actually works, but it clicks on the same location five times.
I've tried other functions, to use this loop, but these will return an error indicating that the object is not iterable.

Hope you could help me out.
Could not find an answer in an earlier raised question similar to this one, if the answer is there, hope you could link this page for me.

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
RaiMan (raimund-hocke) said :
#1

--- I understand that the findAll function will return all locations of the images found
read: http://sikulix-2014.readthedocs.io/en/latest/region.html#Region.findAll

--- your code:

count = 0
findAll("checkbox")
for x in findAll("checkbox"): # apparently only one checkbox is found
    while count < 5: # this loops 5 times with the same x
        click(x)
        count = count +1

--- how to use
checkboxes = list(findAll("checkbox")) # all found unsorted
print len(checkboxes) # get the number found
for box in checkboxes: # loop through all found
    print box

Can you help with this problem?

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

To post a message you must log in.