Can't extract data from an input field [Katalon Recorder]

Hi, I’ve been trying to extract data from an input field, but it keeps returning an empty variable. Is there a way to do this within Katalon Recorder?

Thanks in advance.

1 Like

Hi there, and thanks for posting in the Katalon community! :hugs:

To help you faster, please review our guide on Katalon Recorder here: Katalon Recorder overview | Katalon Docs. Double-checking the steps and configurations might resolve the issue.

If the doc doesn’t help, feel free to provide more details, and a community member will assist you soon. Thanks for being a part of our community!

Best,
Albert Le

@samuelyong91

You used storeText command to fill the recordName.
You used storeValue command to fill the formFieldName.
You used 2 commands.
Why?
Why don’t you use the storeText command for both variables?

Hi. I did write storeText for both. The storeValue in the screenshot is just me trying out a different command. In the screenshot below, you can see that I’ve tried storeText too. But it still doesn’t extract the data from the form field.

Possibly the XPath expression is wrong; it does not correctly select the HTML element you want.

Why? — Only you can debug it because only you can see the HTML source of the page. Nobody else can.


You should test the XPath using Google DevTools. Learn it by the following article:

In between the 1st storeText command and the 2nd storeText command, you have a click command. The click command may trigger a page transition which could take several seconds. Then the 2nd storeText must be fired only after the transition ceased and the page has got settled.

You may want to insert a pause command before the failing storeText command.

Or you may want to try wait* commands, like

I’ve tried what you suggested by getting the xPath from the browser inspector and confirming that it leads to the correct element. I’ve also added a Pause command between the click and storeText command, but it’s still not getting the input field data.

Then I guess the HTML element has an empty string in it, therefore the storeText command set an empty string into the variable.

But I am not sure, as you have not showed us the DOM of the page. Only you can see it; nobody else can find the fact unless you show the DOM to us.

How to view the page’s DOM? See

Sorry, I wasn’t aware of that. Here’s a screenshot of the DOM

Your script tried to find an HTML element by xpath //*[@id="name"].

On the other hand, the DOM image you shared does not show an HTML element which could be selected by that xpath //*[@id="name"].

So, the DOM image you showed above does not provide me enough information to evaluate if the xpath expression is valid or not; and if the HTML element has an emtpy string text or something else.

I think that we, the guys in this forum, need the URL of your target web app to be shared so that we can see it in action in browser in our hand. Is the URL a public one accessible for others on the Internet? If yes, could you share the URL?

Sorry, the URL is not available publicly as it is a private website. About the XPath being valid, does this screenshot help? I just confirmed that the XPath leads to the correct element.

Is there any <iframe> tag in the page?

I guess, your <input id="name"> element is placed inside an <iframe>. In that case you need to select frame first. Otherwise, you would fail to select any element inside the frame.

Just below the HTML you show, there is the “Properties” tab (along with “DOM Breakpoints” and “Acessibility”). With your Name object selected, click on that and see if there is any attribute that holds the information you want. Then, you could use that.

The command I think you want is storeAttribute.

@grylion54

Hi, I followed your advice and came across this. Is this what you are referring to? And if so, what do I do from here?

@kazurayam

No, it’s not in an iFrame

I have no more idea.

@kazurayam

Thank you for the help anyways. I appreciate it.

1 Like

If you click on the X inside the filter below the Properties tab that has the filter of “Disc”, then you should get a listing of other “properties” of your object. Then you can look through the list of “properties” and see if any of them have the information you want.
As an example, in your image, the filter already has one item that it is using; “Disc”. This displays the “property” of value and its contents is “Discount 10%”.

The command I think you want is storeAttribute.

@grylion54

Hi, sorry for the late reply. I’ve tried storeAttribute as you said, but I still couldn’t get the value of the input field.

[object Object] should not appear in the source code. This happens when a JavaScript object is directly inserted into the DOM as a string representation.

To fix this, convert the object into a readable format before displaying it. Use JSON.stringify(obj) to serialize it or access specific properties directly, like obj.key.

1 Like