Adding a Do-While step

You can insert the Do-While logic in a test to make a set of steps run in a loop only if a specific condition is met after the first iteration. The test results display iteration details such as the iteration number, status, and test run time. The test tree displays information from the latest iteration, while the results panel displays either the last successful iteration or the first failed iteration, depending on the test run outcome.

Before you begin

You must have completed the following tasks:
  • Ensured that you are assigned a Team Space Owner, Project Owner, or Member with a Tester role to create or edit a test resource.
  • Read and understood the information in Edit branch overview and Create or select an Edit branch.
  • Ensured that your project contains a Web UI test.

About this task

Procedure

  1. Click the Edit button displayed on the Test Editor page.

    The Edit button appears only when no active edit branch is selected.

    Alternatively, right-click the test in the test navigator panel and select Edit.

    The Edit branch dialog is displayed.
    If the Edit branch dialog is not displayed, then go to step 3.
  2. Select an existing edit branch or create a new edit branch.
  3. Drag and drop the Do While element under any test step as required from the Flow catalog in the Catalog tab.
  4. Click the Do While step.
    The step details pane is displayed.
  5. Select the required mode from the Mode list:
    • UI
    • General
    Note:
    The default mode depends on where the Do While step is added. When the Do While step is added within a With step, it opens in UI mode. When it is added outside a With step, it opens in General mode.

    A confirmation dialog is displayed, indicating that switching modes clears the current step configuration.

  6. Click Yes.
    Note:
    • You can switch between the available modes by selecting a different option from the Mode list.
    • If you switch modes after configuring the step, select the required mode and then click Yes in the confirmation dialog. The existing configuration is cleared and the step opens in the selected mode.
  7. You can perform the actions that are listed in the following table to configure a Do While step during a test run:
    Mode Action
    General: Use the General mode to add do-while loop conditions to test steps.
    Perform the following steps:
    1. In the first column, click the Insert Variable icon Insert Variable to select a variable from the list or enter the variable name.
    2. In the Operator field, indicate the basis of comparison of the two operands. Note that the two operands are strings.
      The available operators are as follows:
      • Equals
      • Greater Than
      • Greater Than Equals
      • Equals variable
      • Less Than
      • Less Than Equals
      • Strict Equals
    3. In the third column, click the Insert Variable icon Insert Variable to select a variable from the list or enter the variable name in the Value field for the selected UI Object.

    When you select a variable from the list, the variable is inserted without the ${} notation. When you concatenate a variable with a string, the variable is inserted in the ${variable_name} format.

    UI: Use the Smartshot to set do-while loop conditions for UI elements.
    Perform the following steps:
    1. Hover over a UI element in the Smartshot view, right-click, and then select Use this element as a step target.

      Alternatively, you can drag and drop a UI element from the Smartshot view to the Object identified by section.

      The UI Object type is identified.

      You can replace a static property value with a variable by clicking the Insert Variable icon Insert Variable. During a test run, UI elements can be targeted dynamically based on the variable value.

      When you select a variable from the list, the variable is inserted without the ${} notation. When you concatenate a variable with a string, the variable is inserted in the ${variable_name} format.

    2. Optional: Click Click here to add relative to, specify the relative location in the Location field, and specify the relative object in the UI Object field.
    3. Optional: Click Click here to add alternative identifier, and select a target object from the list in the Target 2 field.

      Alternatively, you can drag and drop an element from the Smartshot view.

    4. You can select the Code checkbox to enter the do while condition in the text box in the JS mode.

  8. Click the Save icon to save the modifications.

Results

You have configured the Do While step to evaluate a condition during a test run. The steps within the Do While block run at least once and continue to run as long as the specified condition evaluates to true.

What to do next

You can run the test and view the results. See Running a Web UI test.