If element not visible - using verifyElementNotVisible boolean return value

Hi,

My if statement seems to be stoping on the if block and not continuing onto the else block, ive ran the script when its true and it runs fine but when the element is visible i want the else block to run. Ive looked on a few other topics but nothing seems to work for me. I assume its just a failure handling issue and im doing it wrong.

if (WebUI.verifyElementNotVisible(findTestObject(‘V9.1 Testing/Page_CIPHR Self Service 9.1.0/span_HR Admin’)))
{
WebUI.click(findTestObject(‘V9.1 Testing/Page_CIPHR Self Service 9.1.0/span_Log Out_glyphicons glyphi’))

WebUI.click(findTestObject(‘V9.1 Testing/Page_CIPHR Self Service 9.1.0/span_HR Admin’))
}
else
{
WebUI.click(findTestObject(‘V9.1 Testing/Page_CIPHR Self Service 9.1.0/span_HR Admin’))
}.

1 Like

Try

WebUI.verifyElementNotVisible(findTestObject(...), FailureHandling.CONTINUE_ON_FAILURE)

@devalex88
I notice the docs are both weak (no treatment of the boolean return value in the examples) and in error (using a timeout not mentioned in the spec). https://docs.katalon.com/katalon-studio/docs/webui-verify-element-not-visible.html

3 Likes

Great, thought it would be something like that - thanks mate :slight_smile:

2 Likes

Hi folks.

Thanks for the report, I added it into our back log and we will fix the documentation to be more consistent.

https://github.com/katalon-studio/docs/issues/173

Regards !

4 Likes

Just going to add this, after using continue on failure the test would be marked as a fail even though it passes becuase the if statement is a variable that will change - this worked for me

1 Like