How to verify element text ((contains)) something

I want to verify element ‘Job Title
Senior Quality Engineer’ contains ‘Senior Quality Engineer’

is there a one line solution for this without ‘if’ solution ?
I tried ‘Senior Quality Engineer
WebUI.getText(findTestObject(‘Object Repository/Pages/Purchasing/MyLocalSite/employmentMenu/jobTitle’))contains(GlobalVariable.jobTitle)
with no luck

Surprising enough, no, there isn’t any 1 line solution.

But there is a 2 lines solution. See

1 Like

If the element, “Job Title Senior Quality Engineer” is displayed in a label, span, or a web table, then WebUI.getText() should work, but if the element is an input, or textarea, then you should use:

WebUI.getAttribute(findTestObject('Pages/Purchasing/MyLocalSite/employmentMenu/jobTitle'), "value").contains('Senior Quality Engineer')
WebUI.verifyMatch(WebUI.getAttribute(findTestObject('Pages/Purchasing/MyLocalSite/employmentMenu/jobTitle'), "value"), ".*Senior Quality Engineer.*", true)

How about:

If you determine it should be WebUI.getText() then how about the below statement combo:

WebUI.verifyMatch(WebUI.getText(findTestObject('Pages/Purchasing/MyLocalSite/employmentMenu/jobTitle')).contains('Senior Quality Engineer').toString(), "true", false)