Issue with Get Text and Verify Element Text

I am getting an issue with getting text from a page with Get Text. Instead of returning the text from within the element, it is returning nothing.
I also get this issue with Verify Element Text in that it no longer gets the text from the page.

I receive this error:

Caused by: com.kms.katalon.core.exception.StepFailedException: Actual text ‘’ and expected text ‘Mrs’ of test object ‘Object Repository/RCGP_Portal/RCGP_Qualifying_Questions/Review/verifyTitle’ are NOT matched.

This is unusual because the last time I ran the test it returned the text and verified the match after, but now the scripts are failing.

Is this an issue with Katalon?


first things first, double check that the testobject does in fact point to the element you are trying to verify, the page might have changed since then
if you have confirmed that the testobject does indeed select the element, then it might be a timing issue
try adding WebUI.delay(5) and see if the problem persist, if this solves the problem, you can look into waiting for the element to have the expected value, rather than waiting x seconds every time

Thanks @kenzie.rigole , I added a delay before and waited for the element to be present, and the element was present but still returned empty text


I am doing a Get Text from this page element using this locator so I can see that there is the right text…it just can’t pick it up for some reason

Try this. Bring up the page, bring up the devtools just like you did in your last screenshot. We’re going to use that $0 you can see to the right of your image. Open the devtools console and type this:


That should work.

Now try this:


If that fails (it absolutely should not) then you MAY have two or more elements with the same ID – that’s a broken (poorly desgined) web page, if true.

Let me know the results.

@Russ_Thomas Okay this is what I got:
And in the script I replaced the xpath locator with a CSS locator (#checkoutPrice)
Sadly still the same issue. It identified the element okay but returned no text

com.kms.katalon.core.exception.StepFailedException: Actual text ‘’ and expected text ‘£1,352.00’ are not matched using regular expression


I assume this works…

document.quesrySelector("#checkoutPrice").innerText = "Russ and Leyla"

If it changes, it means we can talk to the control from JavaScript. In which case, change your Test Case code to this:

String js = 'return document.querySelector("#checkoutPrice").innerText;'
String coPrice = WebUI.executeJavaScript(js, null)
// do the comparison using coPrice

Leyla, the only other thing I can think of, is waiting a little longer before reading the value from checkoutPrice. If it’s populated late (via ajax or similar) you may be reading it too early. Maybe. :upside_down_face:

This is very sad, replaced the code with what you sent me and still it’s returning no text - I think I have decided that the webpage is just rubbish … thank you for all the help

Also the text did change when I changed it to this


All that’s left is timing. Put a (very stupid) 10 seconds delay before you read the value out. If that works, it’s just a timing issue.

Wow that worked! lol, thanks!

1 Like