Introduction
Some frameworks will generate elements with dynamic locators, meaning they might have a different ID with each rendering of the page. For example, a button might have the IDregister_325629
and then register_861951
after the page reloads.
Solutions
1. Change the Settings for the Endtest Chrome Extension
The Endtest Chrome Extension includes aSettings
section that lets you configure it to ignore the ID
attribute.

Settings
section.
2. Write a custom XPath
The element might have a certain attribute with a value that doesn’t change over time. You can write an XPath that locates the element using that attribute, for example:3. Write a custom CSS Selector
The element might have a certain attribute that has a certain value that doesn’t change over time. You can write a CSS Selector which locates the element by using that attribute, like this:[attribute='attribute_value']
But what if we actually need to find out what that ID is?
In order to tackle this situation, we have to use the Execute JavaScript
action and locate the element by using one its attributes.
If the element has the title
attribute with the value Register
, we need to run the following JavaScript code with the Execute JavaScript
action:
Extract Value from JS Variable
option from the Set Variable
action.
More details about writing custom XPaths and CSS Selectors are available in the Finding Elements in Web Applications chapter.