Skip to main content
Version: current

Exception Handling statements

Note:
  • Once a test step is added as any of the control statements, it is not allowed to change into another keyword.

In Manual view

  1. Open a test case in Manual view.
  2. Click on the drop-down icon of the Add button, then choose Exception Handling Statements.
    exception handling statement

  3. To add a keyword under a statement, select that statement, then click Add. A test step is created under that statement.
    exception handling statements in manual view

    Refer to the following table for the usage of each statement:
    StatementDescription
    TryThis statement indicates that all steps within is monitored by exception handlers.
    ThrowSome code must throw an exception before you can Catch an exception. Regardless of what code throws the exception, it always involves the Throw statement.
    CatchWhen there is any issue occurred during the execution of the Try block, Katalon Studio executes all steps within.
    FinallyThis is the last part of the Try-Catch-Finally

In Script view

The Script view of test cases allows you to programmatically define and handle exceptions using Groovy or Java language. For more details about exception handling in Groovy, refer to this Groovy documentation: Try - Catch - Finally.

For example:

   try {
WebUI.openBrowser('')

WebUI.navigateToUrl('katalon.com')

if (WebUI.getText(findTestObject('Object Repository/txt_singin')).length() < 0) {
throw new com.kms.katalon.core.exception.StepFailedException('Value required')
}
}
catch (StepErrorException e) {
this.println(e)
}
catch (Exception e) {
this.println("General issue occurs.")
}
finally {
this.println("Navigate to a page.")
}