← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #156242]: Use for-loop to observe screen

 

Question #156242 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/156242

    Status: Open => Answered

RaiMan proposed the following answer:
now your "observe solution":

-- using lists to store some probes is a good idea, so you can loop
through

--  if exists(list1[0] or list1[1] or list1[2] or list1[3]):
does not do, what you seem to expect: it only and always uses the first variable from left to write, that is not None. Since your list entries are filled, always and only list1[0] is used.
you might do the following:
for i in range(3):
   if exists(list1[i]):
     popup("Failed")
     type(Key.ENTER)
     #Some code that restart the test.

if you always want to walk through all probes in the list, this is even easier:
for probe in list1:
   if exists(probe):
     popup("Failed")
     type(Key.ENTER)
     #Some code that restart the test.

The advantage of the first solution that you could save the index i for
the matched cases, to reuse them later on.

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.