Failure Handling


#1

This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/failure-handling.html

#2

Looking to understand how i might use the failure method in a try catch function? Specifically I would like to move to the next item in the link array upon hitting a 404 page instead of just letting my code fall off a cliff. Just not sure what I should be working around with the pre-build error handling methods.


#3

Hello,
if you want to catch error, you just have to use “FailureHandling.OPTIONAL” in your try instructions.

Example :

boolean browserAlreadyOpenedAtGoodUrl
String currentUrL
try {
	//	com.kms.katalon.core.webui.driver.DriverFactory.verifyWebDriverIsOpen()
	WebUI.switchToWindowUrl(GlobalVariable.url, FailureHandling.OPTIONAL)
	currentUrL= WebUI.getUrl()
	
	if (currentUrL.equals( GlobalVariable.url)) {
		browserAlreadyOpenedAtGoodUrl=true
	}
	
} catch (Exception e) {
	browserAlreadyOpenedAtGoodUrl=false
}