How to verify text element contain string

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”

Hi, try this:

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

5 Likes

Very useful. Thank you

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



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

if (!(mes.toString().startsWith('not successfully'))) {
    KeywordUtil.markFailed('Message does not contain expected text.')
}

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

Hello, could this script converted to Manual mode?