Adding a While step
You can insert the 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
- 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.
- Opened the test in Test Editor. See Editing a Web UI test.
Procedure
-
Click the
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. - Select an existing edit branch or create a new edit branch.
- Drag and drop the While element under any test step as required from the Flow catalog in the Catalog tab.
-
Click the While step.
The step details pane is displayed.
-
Select the required mode from the Mode list:
- UI
- General
Note:The default mode depends on where the While step is added. When the 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.
-
Click Yes.
Note:
- The default mode depends on where the If step is added. When the If 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.
- 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.
-
You can perform the actions that are listed in the following table to configure a
While step during a test run:
Mode Action General: Use the General mode to add while loop conditions to test steps. Perform the following steps:- In the first column, click the Insert Variable
icon
to select a variable from the list or enter the variable
name. - 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
- In the third column, click the Insert Variable
icon
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 while loop conditions for UI elements. Perform the following steps:- 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
. 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. - 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.
- 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.
- Optional: You can select the Code checkbox to enter the If statement in the text box. This allows you to write the condition in the text box in the JS mode.
- In the first column, click the Insert Variable
icon
-
Click the Save icon
to save the modifications.