# Is it possible to verify element text which contains html tag?

**URL:** <https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276>\
**Category:** Miscellaneous\
**Created:** [May 31, 2018, 10:30am UTC](https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276 "2018-05-31T10:30:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Semen\_Vladimirovich](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Semen\_Vladimirovich](https://forum.katalon.com/u/Semen_Vladimirovich)\
**Post date:** [May 31, 2018, 10:30am UTC](https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276/1 "2018-05-31T10:30:40Z")

</div>

I’m trying to match two values using command verifyElementText

Original html looks like this:

firstpart  
secondpart.

The problem is i’m trying to match one string to two strings, cause when you run the test, the actual text looks like this:

```
         'firstpart

           second part.'  

```

and expected value can only be stored in one string

```
           'firstpart second part.'

```

Is there any way to solve this situation, and match both parts of a text to expected values?

---

<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:** [May 31, 2018, 1:41pm UTC](https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276/2 "2018-05-31T13:41:14Z")

</div>

Did you try using regex? You could parse the whole string using \s+ (one or more whitespace characters) or \b (word boundary).

What do you actually get when you extract the text into a variable and print it?

---

<div class="post-metadata">

**Author:** ![Semen\_Vladimirovich](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Semen\_Vladimirovich](https://forum.katalon.com/u/Semen_Vladimirovich)\
**Post date:** [May 31, 2018, 2:14pm UTC](https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276/3 "2018-05-31T14:14:15Z")

</div>

Sorry, i dont understand what you mean.

---

<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:** [May 31, 2018, 8:40pm UTC](https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276/4 "2018-05-31T20:40:55Z")

</div>

Firstly, I need to see what’s printed when you print the text to the log viewer. So get the text using [https://docs.katalon.com/display/KD/[WebUI]+Get+Text](https://docs.katalon.com/display/KD/%5BWebUI%5D+Get+Text)

Then do

WebUI.comment(result)

regex is short for “Regular Expression”. It’s highly likely you can retrieve the text and verify it using a regex.

---

<div class="post-metadata">

**Author:** ![Semen\_Vladimirovich](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Semen\_Vladimirovich](https://forum.katalon.com/u/Semen_Vladimirovich)\
**Post date:** [June 1, 2018, 7:08am UTC](https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276/5 "2018-06-01T07:08:55Z")

</div>

Here is the text from the log viewer:

```auto
[INFO] - В ближайшее время мы свяжемся с Вамидля уточнения деталей заказа.

```

If you copy/paste it, you will notice that there is end of line in the middle. The problem was solved by using string concatenation:

```auto
'В ближайшее время мы свяжемся с Вами' +
'\n' + 'для уточнения деталей заказа.'

```

Thanks for help.

---

<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:** [June 1, 2018, 12:07pm UTC](https://forum.katalon.com/t/is-it-possible-to-verify-element-text-which-contains-html-tag/11276/6 "2018-06-01T12:07:06Z")

</div>

Kudos. Glad you got it working.
