# How to verify text element contain string

**URL:** <https://forum.katalon.com/t/how-to-verify-text-element-contain-string/12853>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [August 27, 2018, 7:06am UTC](https://forum.katalon.com/t/how-to-verify-text-element-contain-string/12853 "2018-08-27T07:06:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bui\_Chi\_Tai](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Bui\_Chi\_Tai](https://forum.katalon.com/u/Bui_Chi_Tai)\
**Post date:** [August 27, 2018, 7:06am UTC](https://forum.katalon.com/t/how-to-verify-text-element-contain-string/12853/1 "2018-08-27T07:06:14Z")

</div>

Hi,

How can I use the key word “Verify Element Text” to check whether message output contain a string.

For example, the content of my message box is “Approve not successfully. Please try again”, I want to check it contain “not successfully”

---

<div class="post-metadata">

**Author:** ![Marek\_Melocik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/marek_melocik/32/371_2.png) [@Marek\_Melocik](https://forum.katalon.com/u/Marek_Melocik)\
**Post date:** [August 27, 2018, 7:14am UTC](https://forum.katalon.com/t/how-to-verify-text-element-contain-string/12853/2 "2018-08-27T07:14:17Z")

</div>

Hi, try this:

```auto
String message = WebUI.getText(testObject)if(!message.contains("not successfully")) {	KeywordUtil.markFailed("Message does not contain expected text.")}

```

---

<div class="post-metadata">

**Author:** ![Bui\_Chi\_Tai](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Bui\_Chi\_Tai](https://forum.katalon.com/u/Bui_Chi_Tai)\
**Post date:** [August 27, 2018, 7:51am UTC](https://forum.katalon.com/t/how-to-verify-text-element-contain-string/12853/3 "2018-08-27T07:51:02Z")

</div>

Very useful. Thank you

Because I use groovy, so it doesn’t have method contains tring, so I use startWith

```auto

```

```auto
def mes = WebUI.getText(findTestObject('DayDuyet/Page_SWIFT EDITOR 2.4/div_Gi duyt thnh cng s RM 9902'))

```

```auto

if (!(mes.toString().startsWith('not successfully'))) {

```

```auto
    KeywordUtil.markFailed('Message does not contain expected text.')

```

```auto
}

```

---

<div class="post-metadata">

**Author:** ![shilpi1](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@shilpi1](https://forum.katalon.com/u/shilpi1)\
**Post date:** [July 18, 2019, 6:24am UTC](https://forum.katalon.com/t/how-to-verify-text-element-contain-string/12853/4 "2019-07-18T06:24:47Z")

</div>

Hi Bui\_Chi\_Tai, I have to verify this error message, please let me help-  
“_ERROR_ This E-mail type code is not allow to update.”

I am using startsWith but it does not work may be because of \* sign in text message

---

<div class="post-metadata">

**Author:** ![teguh.hariyadi](https://avatars.discourse-cdn.com/v4/letter/t/e47774/32.png) [@teguh.hariyadi](https://forum.katalon.com/u/teguh.hariyadi)\
**Post date:** [April 8, 2020, 2:54am UTC](https://forum.katalon.com/t/how-to-verify-text-element-contain-string/12853/5 "2020-04-08T02:54:39Z")

</div>

Hello, could this script converted to Manual mode?
