Work with conditions, loops, or logical steps
Conditions, loops, and logical steps are constructs that can help you control the execution of a test.
Add conditions
To include a condition into the test, use the Condition icon in the top toolbar. You can use conditions to change the flow of the test according to a set criteria.
Each condition splits the execution into two possible branches:
- On Success if the condition evaluated is successful
- On Failure if the evaluated condition was an error or unsuccessful
Conditions are evaluated according to the result of the statement, which should be a validation (such as Find or Textcheckpoint). Therefore, ensure that the function to be evaluated is located in the statement. (Notice that the results used to evaluate the condition can be from any function, including Wait.)
The statement determines which branch of the condition will be taken. Every condition can have a maximum of one command set as a statement. Commands that have nested validations cannot be added as a statement. Not setting a statement means the condition will not work as expected. When a command is set as a statement, we automatically update its On Error policy.
A conditional set of commands (On Success or On Failure) can be left blank and if met will cause the test to continue to the next step after the condition statement. You can double-click the command and view or edit the parameters in the parameters pane.
Example
The following image shows a sample test with a simple condition.
If the Application.Element.Find command succeeds, the Application.Element.Click command on line 5 will run, followed by the Comment command on line 9. The following image shows a successful run.
If the Application.Element.Find command fails, lines 7, 8, and 9 will run instead. The following image shows a failed run.
Create loops
Use loops in the test to repeat a set of commands a predetermined number of times.
You can also select the iteration type as a DataTable instead of repetitions. For automated commands, each iteration uses the data of the active row of the DataTable.
To add a loop to your test, use the Loop icon on the top toolbar.
When repetitions are specified, the system will iterate the command according to the defined number.
When a DataTable is selected, the system will iterate the command as per the rows of the selected DataTable.
-
Open an existing test or create a new one.
-
Select the commands to be repeated in your test.
To select several commands, Shift-click (Windows) or Command-click (Mac) a command and then select adjacent commands at the same level.
It is not possible to select a nested command along with a command at a higher level or to select commands that are not adjacent.
-
Double-click the loop created in your test.
-
In the parameters pane, select one of these options:
-
Select the number of times the loop should be repeated.
-
Select a DataTable to be added to the loop.
-
Use logical steps
Logical steps are created by combining a group of commands. A logical step can also be included within another logical step.
-
Open an existing test or create a new one.
-
Select the commands you want to combine into a step.
-
Click the logical step icon .
-
Double-click a logical step.
-
In the parameters pane:
-
Select the checkbox next to the parameter you want to add.
-
Add the value of the parameter.
-