Do While loop with Element exist

my click activity has to run till the element (trashcan) NOT exist anymore. then do the next step.

in this case deleting all trashcans in the do while loop…then next step


I couldn’t get the query completely
Pls elaborate a bit more about that

the element exists inside the do while should be of that trashcan, rest all looks good


Can you inspect the Trash icon element?
Check the selector and you can make that dynamic to click on the available trash element

Hope this may help you


Hi @Nightowl_music ,

Can you please help to understand if you getting an exception in the workflow (if so, please post the exception message) or its just that your loop is not getting executed correctly ?

the element is also the trashcan, so it has to click till all trashcans are deleted.

Can you confirm if the selector of the element exist is still pointing to a trash can element. If still facing issue please share the selector of the Element Exist activity ?

Dear NightOwl,
You have to use a While loop instead of a Do While
If you want to click on Trash can icon to delete till it appears then please follow the below steps:

1.First check whether element (trash icon ) exists,the result of this activity is a boolean lets say bElementExists.

2.Then use Use a While loop and
- Condition bLoopElmExist
- Place a click activity and
- Element Exits element activity to find the icon ,outcome is a boolean say
bLoopElmExist(Same boolean used in the activity above while loop can
be used as well)
- Assign the boolean variable value result of the above step to

The above solution checks whether the element exists for the first time when you run and sets the boolean.

Then in while condition ,if the boolean result from former activity is true then it executes the activities inside the while loop.
Inside the while loop, it clicks on the trash Icon if the former boolean result is true.
After clicking, it again checks whether the trash icon still exists and assigns the result to the former boolean.
So the while loop will continue till the icon exists, else it will exit the loop.

Hope this helps, if it does then please mark it as a solution to help others in the same boat .

Attaching a xaml for your reference

ForumElemExist.xaml (12.6 KB)

Geetishree Rao