Help Needed to Improve Pharmacy Search Automation – Selecting Correct Search Result and Handling Dynamic Elements

Hello UiPath Community,

I’ve built an automation project where the goal is to search for a specific medication across multiple pharmacy websites, extract key data (such as pharmacy name, product name, and price), and store it in an Excel file in an organized and structured manner. The name of the medication is provided via an Input Dialog at the beginning of the process, and the bot loops through a list of pharmacy URLs to perform the search.

The issue I’m currently facing is that on several pharmacy websites, the correct product is not always the first search result. Sometimes it appears as the second or third item, and my bot currently selects the first item by default, which leads to incorrect data extraction. I need help configuring the bot to properly identify and select the correct product (matching the exact name or partial match criteria) from the list of results before extracting the data.

Additionally, there are other challenges:

  • Some sites display dynamic ads or pop-ups that interfere with clicks.
  • After successful extractions, sometimes selectors become unstable or invalid in later iterations.
  • I use Element Exists and conditionals to handle variations in results (multiple results, single result, or no result), but the flow sometimes fails due to timing or changes in the page layout.
  • The bot is designed to be scalable, handle CAPTCHAs, and the results should be logged continuously and cleanly organized in an Excel file.

I’m looking for advice on:

  1. How to make the search result selection more reliable (e.g., by validating the name or matching a keyword before clicking).
  2. Best practices to handle UI conflicts like dynamic content, layout shifts, or popups.
  3. How to improve selector stability across different search results.
  4. Any general suggestions to make the project more robust and maintainable.

Any help or shared experiences with similar projects would be greatly appreciated!

Thank you in advance.

Main.xaml (110.7 KB)

Hi @Karla_Cristina_Santos_Cam

The selectors you can try fuzzy or cv scope based selectors for making it more relatable
You pass the value you are searching as variable inside selector

For pops up handling you can add parallel flow or pick branch activities

Also you use find element activity to get element you want and then you can use output of that as input for the action you want to perform
I will also try to go through the xml file you have attached

@Karla_Cristina_Santos_Cam

  1. You can use the innertext field to pass the value you want to select using variable and then it should click the matching row
  2. Avpid using style or class related attributes..use more stable attributes like name ,tag,innertext etc
  3. Same as point 2..use ui explorer find the right set of attributes
  4. Use REF..try to modularize

Cheers

Hey @Karla_Cristina_Santos_Cam
1- For selecting product number–
Instead of blindly clicking the first result, build logic to iterate through all results and evaluate their text content before clicking.Use Find Children.Loop through each result with For Each UI Element.Use Get Text (or Get Attribute) to extract the product name.

2-Handling Popups and Dynamic Ads
Use Element Exists or check app estate activity to handle popup .

3-For Selector Scalability
Use Wildcard, Fuzzy selector,Prefer stable attributes like aaname, title, innertext, etc.

4- General Suggestion
Would be use retry scope Add Delays Activity , Use simulate option,Add try catch to handle Exception and try to create your process in reframework.

cheers

Please try to utilize fuzzy search in studio