If-Else with TestProject Recorder
Note: You need agent version 0.65 and above.
With TestProject Conditions feature, you can set up a Condition to check BEFORE the execution of the step, thus achieving the 'If' statement.
You can find the Conditions here:
In the Web Recorder, locate the required step and click on the Advanced Options
And in the Editor/Mobile recorder you will find it in the Step Menu:
If/Else example based on label text
Lets take simple scenario that check for a text label, IF the text we got is the text that is expected we execute the next step, ELSE we ignore it.
For example, we will take the text of the following Label:
Hover over the element, press double shift to freeze it, in Actions pick Get Text:
Save the text into a Parameter.
Next, lets create a step that will type text to a TextArea only if the text is Equal to "TestProject"
And add the condition in the step:
If the text is NOT equal, the step will not execute and will be shown in grey.
In the reports, it will look like so:
If/Else with different test flows
Now let's take another scenario that evaluate the sum of 2 values operation and IF we get the wanted result, trigger flow A (Sub Test A) ELSE triggers flow B (Sub Test B)
- Sum 1+2 and save the result to "value" parameter
- If value = 3 "flow A"
- Else flow B
Here how it achieved with TestProject recorder:
Now we call subtest A if the value from the previous step was 3:
Press on 'Add test as step':
Search the test name:
In the advanced options, we will add the condition
And now the step will show the 'if' symbol:
To launch Flow B (Subtest B) we will check the opposite condition of the previous step, so we will check if it NOT equal to 3:
We have achieved If 3 flow A Else Flow B.
In the reports, you will see flow A execute and flow B skipped: