# Get element text can not match when object text contains html elements

**URL:** <https://forum.katalon.com/t/get-element-text-can-not-match-when-object-text-contains-html-elements/12691>\
**Category:** Miscellaneous\
**Created:** [August 17, 2018, 8:48am UTC](https://forum.katalon.com/t/get-element-text-can-not-match-when-object-text-contains-html-elements/12691 "2018-08-17T08:48:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miran\_Damjanovic](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Miran\_Damjanovic](https://forum.katalon.com/u/Miran_Damjanovic)\
**Post date:** [August 17, 2018, 8:48am UTC](https://forum.katalon.com/t/get-element-text-can-not-match-when-object-text-contains-html-elements/12691/1 "2018-08-17T08:48:32Z")

</div>

Hello

I have a small issue when using Verify Element Text in my test case. The object of which i want to verify the text for contains a   
 and therefor i can not match the actual and expected values.

In short:  
**The web page shows:**  
String1  
String2  
**By inspection (html):**  
String1  
String2  
**Value property for the Verify Element Text (Expected):**  
‘String1  
String2’  
**Actual value being matched:**  
String1  
String2

Anyone have any tips/tricks or similar experience?  
Thx

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [August 17, 2018, 9:46am UTC](https://forum.katalon.com/t/get-element-text-can-not-match-when-object-text-contains-html-elements/12691/2 "2018-08-17T09:46:31Z")

</div>

Hello,  
when i check for text, i’m using verifyTextPresent() - i’m not searching in particular element  
also verifyTextPresent() allows you to use regexp so it’s more flexible  
unfortunately ‘matches’ from xpath does not work (there are few discussions on this around)

---

<div class="post-metadata">

**Author:** ![Miran\_Damjanovic](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Miran\_Damjanovic](https://forum.katalon.com/u/Miran_Damjanovic)\
**Post date:** [August 17, 2018, 10:25am UTC](https://forum.katalon.com/t/get-element-text-can-not-match-when-object-text-contains-html-elements/12691/3 "2018-08-17T10:25:43Z")

</div>

Hi Andrej

Thx for quick answer. Yes i know about verifyTextPresent(), but i do not want to check the whole page for a certain text, just the targeted object/element. Is there no way to verify object text when it contains newlines or similar html tags using verifyElementText()?

Thx

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [August 17, 2018, 10:57am UTC](https://forum.katalon.com/t/get-element-text-can-not-match-when-object-text-contains-html-elements/12691/4 "2018-08-17T10:57:04Z")

</div>

probably using getText() and compare with use of groovy

---

<div class="post-metadata">

**Author:** ![Miran\_Damjanovic](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Miran\_Damjanovic](https://forum.katalon.com/u/Miran_Damjanovic)\
**Post date:** [August 17, 2018, 11:06am UTC](https://forum.katalon.com/t/get-element-text-can-not-match-when-object-text-contains-html-elements/12691/5 "2018-08-17T11:06:23Z")

</div>

ok thank you!
