Tips for web automation

hi community!
Could you give me a tip/help?
I have some web automation, but I see that there is a lot of selector breakage, which causes a lot of errors in my job.
Do you have a tip for web automation? Which activities/selectors are best to avoid these errors?
Thanks!

@amanda.gondim

  • Anchor Base: Use the Anchor Base activity to anchor your elements to stable text or other elements that are less likely to change.

  • Find Element: Use the Find Element activity to ensure an element is present before interacting with it. This can help avoid errors when the element is not yet loaded.

  • Relative Selectors: Use relative selectors to create a relationship between elements. This makes the selectors less prone to changes.
    Optimize Selectors:

  • Remove Unnecessary Attributes: Only keep the attributes that are necessary and stable. Avoid using attributes that are likely to change, such as idx or css-selector.

  • Use Wildcards: Use wildcards (*) to handle dynamic parts of the selectors. For example, if an ID contains dynamic numbers, you can use id='item-*'.

  • Dynamic Selectors:

  • Variables in Selectors: Use variables within your selectors to handle dynamic data. For example, if you need to click a button with a dynamic ID, you can use "<webctrl id='" + dynamicID + "' tag='BUTTON' />".
    Retry Mechanism:

  • Retry Scope: Use the Retry Scope activity to retry actions in case of temporary issues. This can be useful for handling elements that are slow to load or change dynamically.

  • Error Handling:

  • Try-Catch: Use Try-Catch blocks to handle exceptions and define fallback actions. This ensures that your automation can recover from errors gracefully.
    Use UiPath Explorer:

  • Visual Tree: Use UiPath Explorer to navigate the visual tree and select more stable and unique attributes.

  • Validate Selectors: Regularly validate selectors to ensure they still point to the correct elements.

Recommended Activities

  1. Click and Type Into:
  • Use these activities with properly configured selectors. Combine with Find Element to ensure elements are available.
  1. Get Text and Get Attribute:
  • Use these activities to retrieve text or attributes from elements. These can help in validating the presence and correctness of elements.
  1. Element Exists:
  • Use this activity to check if an element exists before interacting with it. This reduces the risk of errors due to missing elements.
  1. Wait Element Vanish and Wait Element Appear:
  • These activities help in synchronizing your workflow with the web page load times and element visibility.

Hi @amanda.gondim ,

For stable web automation, use “Anchor Base” for stable elements near dynamic ones and wildcards (*) in selectors to handle changing attributes. Leverage “UI Explorer” for robust customization. Regularly update selectors to adapt to webpage changes. Additionally, modern activities offer better stability and reliability.

Regards
Sandy