Stop loop if an element appear

Hi everyone! I have the following problem. I have to scroll down a certain number of times until the following prompt appears
image
The thing is that I don’t know how to recognize when the prompt appears on the screen, in order to click OK and then the scroll down cycle ends.

HI @Cam1

Use While and scroll inside while. Put while and element exists in a parallel activity and give the output of element exists in the parallel condition(with not) so that the loop runs till the element exists turn to true. give the selector of your pop up. In the while condition you can add the same output from element exists(with not) so that the loop stops once the element is found

cheers

1 Like

Use Check App State to see if it appeared.

You use Break to exit a loop, but that’s not what you should do here. You want to create a boolean variable and initialize it to False. Name it something like “LastRecord”

Then you use a Do While, with the condition “NOT LastRecord”. Inside the Do While, click the scroll down (or keyboard command, however you’re doing it) and Check App State to see if the popup appeared, with LastRecord in the output property. If it did appear, then click OK. If it did not appear, do nothing and the Do While will loop.

1 Like

There’s no point to parallel here. Just need a Do While and Check App State.

Hi @postwick

This will save time as well…else element exists will be checking always. IN parallel it will be quicker. Else I agree there would not be much difference

cheers

It won’t. That’s not how Parallel works. It doesn’t actually execute activities at the same time.

Use retry scope where element exists is the condition. You may choose to set properties as needed.

1 Like

Hi @postwick

I agree it does not execute at once. but it still checks both syncronously which is not a sequence for sure. SO definitely there is a difference

cheers

Thank you all for your help! I’ll try what works best. I appreciate your answers

1 Like

(post deleted by author)

try using a check App State to see if it appeared

Yes. I tried that and works fine, thank you!