Katalon studio if else verifyTextPresent problem

Hello everyone,

I would like to provide test if there is any 502/504 error on page (that’s needed for now) and if not - continue to login. I used to make it several forms - if(condition) than if(!same condition), without second if, but using else, and if else. But nothing works and KatalonStudio cannot continue, because “Unable to verify text ‘502 Bad Gateway’ is present using regular expression”. Please help if there is any possible way to solve it.

This is my code sample (one of many attempts):

public void internalLogin(){
WebUI.navigateToUrl(’***’)
if(WebUI.verifyTextPresent(‘502 Bad Gateway’, true)){
KeywordUtil.markFailedAndStop(‘MANUALLY STOP: 502 Bad Gateway, page doesnt recognise’);
}else{
WebUI.setText(findTestObject(‘username’), ‘username’, FailureHandling.OPTIONAL)
WebUI.setEncryptedText(findTestObject(‘pswd’), ‘password’)
WebUI.click(findTestObject(‘Page_Login/button_Login’))
}
}
}

Regard

Hi, use the FailureHandling.OPTIONAL to make the else statement possible

if(WebUI.verifyTextPresent('502 Bad Gateway', false, FailureHandling.OPTIONAL))

And ‘502 Bad Gateway’ is not a regular expression, so you can use false.

You will have a warning in the log for the text not present, but the else statement will run

2 Likes

Thank you very much, Helene

You’re welcome !

Thank you …it helped me.