Search for UI element dynamically across all pages of website


I have to search for an UI element which is a string (can be a name of an individual) across all
pages of the website. I’m using a try catch where in catch I want to insert activities if “a text not found” exception occurrs. But I’m not sure what to enter in catch section activities- such that if a text not found exception occurs in first page of website then it should search it in all the pages until it is found, and once found click on it and continue with the similar steps. If not found at all then gives an error message and goes to the next item in for each loop. (I have used a for each loop here in the try section)

Any help is highly appreciated. Thank you!

Hello @Swati4 ,

The catch as its name suggests is a place to catch your errors/exceptions and either return them to the caller of that process or sink it entirely before proceeding to the next item in the loop.

For example in your case, the Try-Catch may look something like this:

For Each currentPage in ListOfPages

   Navigate to currentPage 
   Find Element on currentPage 
   Use the name you found for your business actions
   Break if element is found on current page
Begin Catch (Exception Ex)
   'Sink your error here by reporting that the element was not found on the current page
   Write Log "The name " + varName +" was not found on page "+ currentPage + ". Moving to 
   next page ..."
End Catch

'  Move to the next page in the list

Obviously, this example assumes that you have the list of pages you want to search the element is present in a list that you can loop through.

Hope this helps

Hi Sir,

Thank you for your response. My apologies if i was not able to explain it well in previous post.

Sir my use case is- I have a for each loop which lets say contains 10 texts strings (individual names), now im searching these on a website which has 5 pages, in the first page it could find two items from the loop and did the further activities, but when it goes to the third item
it did not find that in first page and now i want the bot to go to the next page and find the item which was not not found in 1st page, and if it was not found in second page as well then go to next page and search, if at all it was not found in any page then give a error message and go back to the next item in loop and do the respective steps. To go to one page from the previous, there is just a small arrow in right down corner of the 1st page.

I’m a beginner in UiPath, learning while trying to execute this. Thank you so much for your help here.

Hi @Swati4
Did you manage to get a solution to your problem? I have the same situation currently and need some advice on the best way to go about this. Would appreciate it.