I can't create condition to run another loop (to automate clicks on www.neobux.com)

Good afternoon. I can’t create a condition for the first loop to stop, when it no longer finds the elements on the screen. The amount of these elements varies in amount and I would like it to run the next loop when this first one doesn’t find the elements on the screen.

Sorry for the question, I’m new to programming.

Hi @Rafael!

In this specific case, it seems to be missing the i+=1 statement at the end of the while block. As it is in print, what is inside the while will always be executing and the else block will not be accessed, even if the elements are not found.

However, if you use i+=1 the while loop will only be executed once.

If I understand correctly, you would like to make a condition based on the elements that are searched for, right? In this case, one possibility would be to use the construction of self.find(...) as the loop condition itself, for example:

while self.find(label="element1", matching=0.97, waiting_time=10000) and self.find(label="element2", matching=0.97, waiting_time=10000):
      # Do something

In the above case, the loop will only continue to run as long as “element1” and “element2” are found on the screen. When one of the elements is not found, the loop stops.

If your case is something like this, then you can use a similar construction and create the condition that is necessary.

1 Like

It worked, thank you very much for the answer.