Skip to main content

Branching 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. Click on the drop-down icon of the Add button, then choose Branching Statements.
    Branching statements
  2. To add a keyword under a statement, select that statement, then click Add . A test step is created under that statement.
    branching statement in manual view

    Refer to the following table for the usage of each statement:

    StatementDescription
    BreakKatalon Studio exits the current code block and continues to the next code block/test step.
    ContinueKatalon Studio skips the remainder of the current loop and continues with the next iteration of the loop.
    ReturnKatalon exits from the current method/step, and the flow control is returned to where the method/step was invoked.

In script view

The Script  view of test cases allows you to programmatically define and handle Break , Continue and Return , using either Groovy or Java language. 

For example:

  • Break :
for (int i = 0; i < max; i++) { // interested only in p's if (searchMe.charAt(i) != 'p') { break; } // process p's numPs++; }

  • Continue :
for (int i = 0; i < max; i++) { // interested only in p's if (searchMe.charAt(i) != 'p') { continue; } // process p's numPs++; }

  • Return :
for (int i = 0; i < max; i++) { // interested only in p's if (searchMe.charAt(i) != 'p') { return true; } // process p's numPs++; }

Was this page helpful?