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.
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 Do While element under any test step as
required from the Flow catalog in the
Catalog tab.
-
Click the Do While step.
The step details pane is displayed.
-
Select the required mode from the Mode list:
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.
-
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.
-
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 |
Perform the following steps:
- Select a variable in the Value 1 list.
- 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
- Enter a value to be compared with the value of the selected variable in
the Value 2 list.
|
| UI |
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.
- Enter a property name such as Content, Id, or XPath of the object in the
UI Property
field.
If you entered the property name correctly, the value of the property is displayed under Extracted Value. You
can select the Code checkbox to enter the do
while condition in the text box in the JS mode.
|
-
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.