Dynamic IDs in Web Recording / Customize Recording Selector Strategy

Let me assume your HTML is like this:

<html>
<body>
<input id="loginButton_2546897">
</body>
</html>

When you use Web Recorder to generate a TestObject to select the input element, Web Recorder will generate a Test object with following locator:

//input[@id='loginButton_2546897']

Next time you visit the page, you may see the dynamic portion of the id changed.

<html>
<body>
<input id="loginButton_01234567">
</body>
</html>

The TestObject will fail to select the input element.

How to mange this case?

Once you have saved the Test Object, you can manually edit its locator as follows:

//input[starts-with(@id, 'loginButton')]

The modified locator will work even when the “dynamic portion” in the id value changes in future.

You should edit generated locators manually to customise them to suite your needs.