Is there a best practice for creating selectors so they continue to work when a website is updated

Best practices for building good selectors
The hardest part of development is to ensure you have strong selectors in place. Good selectors minimize impacts when the element robot interacts with changes its appearance or position in the screen

Following guidelines helps in building resilient selectors while minimizing the impact when there are changes.

  1. use UiPath Explorer and go through the visual tree to strengthen your variable
  2. use aaname attribute of the selector matching with the visible name or label of the fields
  3. use variables when element name changes dynamically based on data input.
  4. Avoid using class attributes if possible.
  5. DO NOT use css-selectors or any attributes related to the styling of the page (to avoid impact to the bots due to any appearance changes)
  6. DO NOT use idx attribute - this is a dynamic variable and changes depending on the time element loads on the page.
  7. DO NOT use OCR for selectors unless there is no other option.
  8. Use Attach browser or attach window activities to minimize number changes to top-level selectors
  9. use Browser variable input instead of hardcoded selectors in the attach browser activity.
  10. Library for UI Interation of the application: if the application involved frequently changes the UI, consider building the Library and add all the activities which interact with the UI of that application in it.
    this way when there is changes to the UI, you can update the library and reference the new version of it in the dependencies of the UiPath Project using this application.
8 Likes