If / Else

If / Else enables a test case to follow different execution paths depending on whether a specified condition evaluates to true or false, allowing dynamic and logic-based test execution.

If certain steps need to be executed only when a condition is true (for example, login is successful), add them under the If section. If the condition is false, alternative steps can be added under the Else section.

  • Click "If / Else" to add a conditional block in the test case.

  • Set Condition for If -Choose how to set the condition:

    • Element

    • Parameter

  • Element -Choose "Element" when the condition depends on an object (UI element, text, etc.) on the screen.

    • From the dropdown, select the required option:

      • Conditions (is visible, is not visible)

      • Actions

      • Interactions(click, type, focus..)

        • Example: To check if the "Login Successful" message is visible after clicking the login button:

          • If the message is visible → condition is true

          • If not → condition is false

  • Select the required "Object" (stored using XPath / Playwright).

  • Click "Save" to apply the condition.

  • Parameter - Choose "Parameter" when the condition depends on a value.

    • From the 1st dropdown, choose an existing parameter OR Click "Create" to add a new parameter:

      • Enter Name (e.g., login_status)

      • Enter Value (e.g., success)

      • Select Type (String, Number, etc.)

      • Click Create

    • From the 2nd dropdown, select the comparison type (equals, not equals, greater than, less than, contains, etc.)

    • Enter the comparison value (e.g., success)

      • Example: To check if the login status is successful:

        • If login_status = success → condition is true

        • If login_status ≠ success → condition is false

    • Click "Save" to apply the condition.

  • If (True Condition Steps)-Add the required steps under If.

    • These steps execute only when the condition is true.

  • Else

    • Add the required steps inside the "Else" section.

    • These steps execute only when the If condition evaluates to false.

      • Example: If login is not successful:

        • Show error message

        • Retry login

        • Capture screenshot

    • If needed, update or modify the description

    • Click "Save" after changing description

  • Else (False Condition Steps)-Add the required steps inside the Else section.

    • These steps execute only when the condition evaluates to false.

  • End If

    • End If marks the end of the If / Else condition.

    • It closes the conditional block and completes the flow.

    • If needed, update or modify the description

    • Click "Save" after changing description

  • Example Flow

    • If login is successful:

      • Perform dashboard actions

    • Else:

      • Show error and stop execution

    • After End If:

      • Continue with remaining test steps

Last updated