Dynamic IDs in Web Recording / Customize Recording Selector Strategy

Hi,
I have a problem using Katalon Studio using Record Web feature. Because my colleagues have to put Dynamic IDs to some elements on our websites. We just can’t get rid of them. So instead of let’s say #loginButton, we have #loginButton_2546897. In all those cases, where we have to use dynamic IDs, we also have name, which is also unique, but without that number. Now when some of our testers records web page, they can’t just replay it, because they have to switch all element locator with Dynamic IDs to use name instead. It is unnecessary work we have to do.

So my question is: Is there any way I can configure Web Recording feature to work well with DynamicIDs? Is there any way I can customize locator strategy of Web Recording to suite my needs? I am a programmer, so any non-trivial hack to customize that process is not a problem for me :smiley: :slight_smile:

1 Like

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.

No.

Web Recorder is not as intelligent as you want it to be.

thank you :slight_smile: They could actually make it little bit more customizable, I saw different people here, that would like to customize it, so I hope some of devs will see this and they will add support for it.
It’s sad they didn’t provide more controls for us, programmers, because I would customize exactly the way I want easily, if I had access to it :smiley: