# Issue with Get Text and Verify Element Text

**URL:** <https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899>\
**Category:** Miscellaneous\
**Tags:** start-page\
**Created:** [September 30, 2020, 12:03pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899 "2020-09-30T12:03:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![leyla.hunn](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/leyla.hunn/32/12809_2.png) [@leyla.hunn](https://forum.katalon.com/u/leyla.hunn)\
**Post date:** [September 30, 2020, 12:03pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/1 "2020-09-30T12:03:37Z")

</div>

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?

Thanks

---

<div class="post-metadata">

**Author:** ![kenzie.rigole](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kenzie.rigole/32/22830_2.png) [@kenzie.rigole](https://forum.katalon.com/u/kenzie.rigole)\
**Post date:** [September 30, 2020, 12:15pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/2 "2020-09-30T12:15:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leyla.hunn](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/leyla.hunn/32/12809_2.png) [@leyla.hunn](https://forum.katalon.com/u/leyla.hunn)\
**Post date:** [September 30, 2020, 12:45pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/3 "2020-09-30T12:45:33Z")

</div>

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

![image](https://europe1.discourse-cdn.com/katalon/original/2X/b/b67e59acf687e981e7fca42fb4acda87d49b4b24.png)

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

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 30, 2020, 12:55pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/4 "2020-09-30T12:55:25Z")

</div>

> [@leyla.hunn](#):
>
> 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:

```auto
$0.innerText

```

That should work.

Now try this:

```auto
document.querySelector("#checkoutPrice").innerText

```

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.

---

<div class="post-metadata">

**Author:** ![leyla.hunn](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/leyla.hunn/32/12809_2.png) [@leyla.hunn](https://forum.katalon.com/u/leyla.hunn)\
**Post date:** [September 30, 2020, 1:10pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/5 "2020-09-30T13:10:56Z")

</div>

@Russ_Thomas Okay this is what I got:

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/5/563b393bc354e8109aabf6342259b70c2f71a6da.png)  
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

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 30, 2020, 1:19pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/6 "2020-09-30T13:19:14Z")

</div>

Weird.

I assume this works…

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 30, 2020, 1:22pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/7 "2020-09-30T13:22:51Z")

</div>

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. 🙃

---

<div class="post-metadata">

**Author:** ![leyla.hunn](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/leyla.hunn/32/12809_2.png) [@leyla.hunn](https://forum.katalon.com/u/leyla.hunn)\
**Post date:** [September 30, 2020, 1:34pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/8 "2020-09-30T13:34:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leyla.hunn](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/leyla.hunn/32/12809_2.png) [@leyla.hunn](https://forum.katalon.com/u/leyla.hunn)\
**Post date:** [September 30, 2020, 1:35pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/9 "2020-09-30T13:35:23Z")

</div>

Also the text did change when I changed it to this

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/b/bfe8d16adfe167b63127920c22114fec308b56eb.png)

Outcome:

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/1/155a50ad62e614d4b0292a9c101173ecc8453ae1.png)

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 30, 2020, 1:40pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/10 "2020-09-30T13:40:12Z")

</div>

> [@leyla.hunn](#):
>
> This is very sad, replaced the code with what you sent me and still it’s returning no text

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.

---

<div class="post-metadata">

**Author:** ![leyla.hunn](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/leyla.hunn/32/12809_2.png) [@leyla.hunn](https://forum.katalon.com/u/leyla.hunn)\
**Post date:** [September 30, 2020, 1:50pm UTC](https://forum.katalon.com/t/issue-with-get-text-and-verify-element-text/47899/11 "2020-09-30T13:50:53Z")

</div>

Wow that worked! lol, thanks!
