Hi,
I’m currently working on a script where I need to verify if the text exists but somehow I couldn’t figure out what needs to be added or edited.
Scenario:
Check if “No data available in table” text is present if yes Close Browser
If statement number 1 is not present, Check if “Ref” text is present if yes Close Browser
Here is my script:
WebUI.click(findTestObject(‘Object Repository/7. Transactions/td_No data available in table’))
if (WebUI.verifyTextPresent(findTestObject(‘No data available in table’,true), 1, >FailureHandling.OPTIONAL)){
WebUI.closeBrowser() {
}}
else (WebUI.verifyTextPresent(findTestObject(‘Ref’,true), 1, FailureHandling.OPTIONAL)){
WebUI.closeBrowser()
}
WebUI.click(findTestObject('Object Repository/7. Transactions/td_No data available in table'))
if(WebUI.verifyTextPresent('No data available in table', false, FailureHandling.OPTIONAL)){
WebUI.closeBrowser()
} else {
if(WebUI.verifyTextPresent('Ref', false, FailureHandling.OPTIONAL)) {
WebUI.closeBrowser()
}
}
Verify Text Present expects to find the text somewhere in the page source. It will not find it if it exists only as a value in an <input> element or <select> element etc (I believe).
What you are doing is comparing the element’s “value” attribute to a specific text. Whether the text is “Hamish” or a String variable wouldn’t matter. I do this quite regularly.
Compare the text to a String variable:
WebUI.verifyMatch(WebUI.getAttribute(findTestObject(‘LName’), ‘value’), sLastName, false)