FailureHandling Change breaks legacy code (was STOP_ON_FAILURE does not stop a test when verifyElementPresent returns false)

I think this confirms the behavior of verifyElementPresent now behaves as it did previously (as per @Jass’s post here).

The code tested in Katalon Studio 7.0.10:

wam('Nav to Katalon "About us" page')

WebUI.navigateToUrl('https://www.katalon.com/about-us/')

WebUI.waitForPageLoad(10)

wam('Check some links are accessible')

WebUI.verifyLinksAccessible(['https://www.katalon.com/resources-center/blog/', 'https://www.katalon.com/partners-and-contributors'])

wam('Create a null test object')

TestObject to = null

wam('Try to verify a null test object (1)')

if (!(WebUI.verifyElementPresent(to, 5, FailureHandling.OPTIONAL))) {
    wam('null object, OPTIONAL')
}

wam('Try to verify a null test object (2)')

if (!(WebUI.verifyElementPresent(to, 5, FailureHandling.CONTINUE_ON_FAILURE))) {
    wam('null object, CONTINUE')
}

wam('Try to verify a null test object - THIS SHOULD STOP THE TEST! (3)')

if (!(WebUI.verifyElementPresent(to, 5, FailureHandling.STOP_ON_FAILURE))) {
    wam('null object, STOP (shouldn\'t see this)')
}

wam('Test should NOT reach this line!')

Result.

Reminder: Numbered lines in the output are NOT warnings – that’s how wam comments work in my Katalon test environment.

Key point: STOP_ON_FAILURE now prevents all subsequent code from executing when the element does not exist. There is no sign of the last two comments in the output.

2 Likes