Why the recorder using the button text instead of the unique id?

We have a problem in Katalon Studio. Our customer is using Katalon Studio.
We have 3 buttons that have a unique id. But when I check the script mode all the 3 steps are clicking on the same button.
Why it i not taking the unique id? Instead it is taking the button text. And how can we solve this issue?

We don’t know anymore what to do. We also don’t have another option to select.

Here you can see the buttons from the development tools:

When I check the script mode he is given for every button:
WebUI.click(findTestObject(‘Object Repository/*** - _3c37a1/span_Opslaan’))
The *** to cover sensitive data

Katalon recorder do use everywhere the wrong XPATH as we think (when I check the settings locator tab).
(.//*[normalize-space(text()) and normalize-space(.)=‘Nee’])[2]/following::span[1]

When I check the tab attributes I have the choice between this:

What to do now and why did happen?

It is taking the button text because you selected the ‘Detect object by?’ of the ‘text’ checked ON and other rows OFF, as the screenshot shows:

Please find
Project Settings > Test Design > WebUI > "Decide the attributes used for locating an object"

Possibly you have the “id” is unchecked. Spy & Recorders does not use the “id” because you told to do so.

The Recorder tool is for those who do not know what XPath is.

If you are capable to find the correct XPath expressions, then you do not have to use the Recorder tool. You can write the locators manually.

Ah I will check. Also with the customer.
The customer use the recorder tool because he do not know what XPath is. He doesn’t now anything about programming. Therefore he do use the record tool

I would recommend him (your customer) to have a look at an introduction to XPath.

Provided that he got a brief understanding what XPath is, then the Recorder tool may help. Without any understanding what XPath is, the tool will fall short for helping him.

1 Like

This didn’t solve the problem.
The customer did try it. He is saying that htere is under Object Repository only 1 span_Opslaan made for the 3 save buttons.
What can we do now?

I would recommend to your customer to stop using the Recorder & Spy tool. Because it is likely that the HTML of the target web page is coded in a way that makes the Katalon Recorder tool confused.

Please be advised that the Recorder & Spy tools are not necessarily capable of providing good TestObjects for you. It depends on the way how the target HTML source code is coded: whether it is coded friendly to the tools or not.

Your customer wants to create 3 Test Objects manually as follows:

Test Object name locator in XPath
ObjectRepository/***/button_save-project-button //button[@id='save-project-button']
ObjectRepository/***/button_save-kkb-button //button[@id='save-kkb-button']
ObjectRepository/***/button_assortment-attach-submit-button //button[@id='assortment-attach-submit-button']

In my humble opinion, provided that you are skilled enough for HTML and XPath/CSS Selector technologies, it is often easier to create test objects with appropriate locators manually than struggling with the tools. The tools can not automatically infer what you want them to do.


because the HTML of your web page is coded in a way the poor Recorder is tricked.

My theorem

Let me assume an alternative case where the HTML has the following code structure:

<button type="submit" ... id="save-project-button">Opslaan</button>

Please note that this button element has no child <span> elements. In this case, when you operate the Recorder, you will give a click event to the <button> element, and the tool will generate following locator:


However, actually your HTML has different structure as this:

<button type="submit" ... id="save-project-button>

Please note that a <span> element is contained in the <button> element. When you operate the Recorder tool, open the page in browser, you will give a click event to the <span>Opslaan</span> element, not to the parent <button> element.

The Recorder is designed, I think, to generate a locator which points the element that received your click event. So the generated locator will be like this:


The Recorder tool is not capable to generate a locator for the parent button element automatically & intelligently .


Your target HTML has a structure too difficult for the Recorder tool to generate a good locator (= a good Test Object) that you really want. The tool is tricked by the HTML structure of your target web page.

In this difficult case, you should create Test Objects manually. It is far easier than struggling to force the tool behave as you like.

I am afraid that your customer would not understand what I explained here. He would start complaining about the tools. Let it go. I can do nothing for him.


Thank you very much kazurayam.
I will tell also our architect so that he also knows about the problems.
I think we need to help the customer a lot then.