Skip to end of metadata
Go to start of metadata

Katalon Studio provides the ability to dictate the logical flow of execution by supporting control statements such as If/Else, for/while or Try/Catch… which are very common concepts in programming language.

The following control statements are supported in Katalon Studio:

 

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

 

Decision-making statements 

In Manual view 

Open a test case in Manual view, then navigate to Decision-making Statements from command toolbar.

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

StatementDescriptionScreenshot
IfThis statement requires a boolean condition as input value. Katalon Studio will execute all steps within once the condition is triggered.

Else IfUsing Else If after If, you can create a combination of conditions where the steps within the first satisfied condition will be executed.
ElseThis statement serves as the conclusion of the If - Else If - Else structure. The steps within this statement will be executed if all the conditions above it are not triggered.
SwitchThis statement requires an expression, which is often referred to as the control expression (or control variable), as input value.

Case

The Cases indicate the assumed value for the control expression, with corresponding steps to be executed when a match occurs.

Each Case will have a Break by default which should be positioned at the end of the Case block to mark the end of it.

DefaultThis statement is included automatically within every Switch statement. In situation which no Case value can be matched, the steps within Default will be taken.

In Scripting view

The Script view of test cases allows you to programmatically define and handle If-ElseIf-Else or Switch-Case structure easily using either Groovy or Java language. Refer to http://groovy-lang.org/semantics.html#_conditional_structures for more details about conditional structure in Groovy.

For example:

Decision-making statement

Screenshot

If - Else If - Else

 

Switch - Case

 

 

Looping statements 

In Manual view 

Open a test case in Manual view, then navigate to Looping Statements from command toolbar.

Refer to following table for the usage of each statement:

StatementDescriptionScreenshot
ForThis statement accepts a range, list or array as input value so that Katalon Studio knows how many times to execute all steps within the For structure.

WhileThis statement requires a boolean condition as input value so that Katalon Studio will keep executing all steps within until the condition fails.

In Scripting view 

The Script View of test cases allows you to programmatically define and handle For or While structure easily using either Groovy or Java language. Refer to http://groovy-lang.org/semantics.html#_looping_structures for more details about looping structures in Groovy.

For example:

Looping statement

Screenshot

For

While

 

Branching statements 

In Manual view 

Open a test case in Manual view, then navigate to Branching Statements from command toolbar.

Refer to following table for the usage of each statement:

StatementDescriptionScreenshot
Break

Katalon Studio will exit current code block and continue to next code block / test step.

ContinueKatalon Studio will skip the remainder of the current loop and continue with the next iteration of the loop.

ReturnKatalon will exit from the current method/step, and the flow control is returned to where the method/step was invoked.

In Scripting view

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

For example:

Decision-making statement

Screenshot

Break

Continue

Return

 

Exception handling block 

In Manual view 

Open a test case in Manual view, then navigate to Exception Handling Statements from command toolbar.

Refer to following table for the usage of each statement:

StatementDescriptionScreenshot
TryThis statement indicates that all steps within will be monitored by exception handlers.

ThrowBefore you can Catch an exception, some code must throw one. Regardless of what throws the exception, it's always involved with the Throw statement
CatchKatalon Studio will execute all steps within when there is any issue occurred during execution of the Try block.
FinallyThis is the last part of the Try-Catch-Finally structure and all steps within this will be executed regardless of any exception.

In Scripting view

The Script view of test cases allows you to programmatically define and handle exception easily using either Groovy or Java language. Refer to http://groovy-lang.org/semantics.html#_try_catch_finally for more details about exception handling in Groovy.

For example:

 

  • No labels