My Team's Automation engineers are trying to automate the testing for the applications. They are using id for input fields to create x paths. The problem when the tab is refreshed, the ID's for the same field is being changed in the html. Can we keep any unique identifier for creating x paths?
Discussion posts and replies are publicly visible
Don’t use the changing HTML id for XPath because it is dynamic and can change on refresh. Use a stable locator instead, such as label text, name, aria-label, or a partial XPath with contains() / starts-with() if a fixed prefix exists.Similar Post - https://community.appian.com/discussions/f/rpa/31005/how-to-use-xpath-as-a-browser-action-selector-which-is-changing-dynamically
Hi vijayp6380 ,We can’t rely on Appian generated HTML IDs, they are dynamic in nature as they are generated at runtime, even we have also faced this.
Instead, we had done few workarounds,
1. Use Attributes such as - Labels, Placeholder text, Tooltips.
2. Using Relative Xpaths instead of Absolute Xpaths.
3. Use Nearby anchors.
4. If you are using automation tools like selenium, use predefined functions like getByLabel().
Note: Try to use unique label names, Placeholder Text, Proper tooltips to help the debugger understand the DOM elements.Hope this will solve your issue! Happy to help further!