Skip to main content

Looping 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 the  Manual  view. Click on the drop-down icon of the Add button, then choose Looping Statements.
  2. To add a keyword under a statement, select that statement, then click Add.
    Looping statement

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

    StatementDescription
    ForThis statement accepts a range, list, or array as an 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 the input value so that Katalon Studio keeps executing all steps within until the condition fails.

In script view

The Script view of test cases allows you to programmatically define and handle For or While structure using Groovy or Java language. For more details about looping structures in Groovy, refer to this Groovy documentation:  Looping Structures .

For example:
  • For:

    for (def index : (0..5)) { WebUI.acceptAlert(FailureHandling.STOP_ON_FAILURE)
  • While:

    while (varA == true) { WebUI.acceptAlert(FailureHandling.STOP_ON_FAILURE) }