How to avoid Click events on certain screen regions

I am clicking on list item by looping through them using selectors. But, after finishing clicking on the last item in the list, the mouse goes somewhere else in the screen and clicks on the Default checkbox button under the Departments section instead of terminating the application.


I have tried checking if the tag attributes match to modify the selectors but they differ. In addition, I have tried using the Element scope activity to perform the clicks only within a certain region which i highlighted but get the following message when i run it normally:


may i know which activity you are using to loop across
Cheers @michaelamay0

Just a while loop and i’m passing updated variables into the selectors, once there is an exception say the list item is not there i break out of the loop.

hi, @michaelamay0
you can use an activity “element exist” in selector position, after each round of the cycle, and ask if the element exists, if it exists, it returns and enters the cycle, otherwise, it means that the cycle has ended and the activity ends. See the example.

pdt: inside the “Do while” loop, use the respective actions you need to execute.
Regards, FZ.

can i have a view on that while loop with a screenshot
because if we are using while loop then we will be a counter to increment each time
that would probably stop the iteration when the counter meets the limit
but still if we are facing the issue then we need to validate that while loop

Cheers @michaelamay0

i attach the example, let me know any issue.

ex.xaml (8.7 KB)


I don’t think the element exist activity will work. For example, we get the index id of the first list item. Then we loop by incrementing this id, pass the incremented id into the selectors of the click activity, and the click activity clicks the next list item. When the increment id is out of range from the amount of list item it simply throws an exception. Thus, everything is based on index not on uielements.

The problem does hold within the while loop in my opinion.


It looks like after the last list item is reach, it goes to a different button on the page and click on it. The only way I can see this happening is that if that button had the similar tag names of the list items but there totally different,not even close. Since with list item we are just updating the numbers when we increment, take a look:


with the element exist, validate if the selector in the position that you are traveling exists, that is why the value of the selector, is the selector that we are traveling, if the index is stored in the selector, then the element exists asks if it exists, while it exists He does the activities.

so instead of boolean variable as condition
if we are sure that we need to go for three clicks the use a condition like this
add <= 3
where add is a variable of type int32 with default value as 1 defined in the variable

as we are using boolean variable it will enter to the while loop inspite of all clicks were done…and click on any other element which would give us then a boolean value of false which will be validating only in next loop right…

so if we use a solid condition like the counter increment it wont even get into while loop if the add meets 3 clicks

Cheers @michaelamay0

The problem is that i don’t know if it will always be 3. The list items can be any number.

Also element exist will always be true since the list item are always there remember. Can we do something in which we say element exist within this region, if true click it, if false throw exception? That’s the main problem here.

if the selector changes when the number of clicks ends, it means that the element does not exist (in selector position) so it exits the cycle