Adding Conditions to Test Cases
Adding conditions to Test Case allows you to perform different actions while executing your test. Conditions in Sofy follow the If and Else statement workflow that can be defined as executing a certain step or skipping it to move onto the next step.
Depending on the OS version, your App surfaces a permissions dialog box, asking the user to select "Allow" or "Don't Allow" as an option before moving to the next step. With the Conditions feature enabled, you can either let the test case continue if the dialog box appears or move on to the next step if the dialog box doesn't appear. With this feature you can now take into account the App behavior depending on the OS version and ensure that the test case is executed as intended.
How to use Conditionals?
- Click on the Automation tab from the left panel on your Home Screen
- Click on the Edit icon (pen) next to the test case inside which you wish to insert a Conditional. For example, let us insert a Conditional inside “test3” here.
- Inside the Edit Test section, select the step over which you wish to insert a conditional. As an example, let us select Step 2.
- In the action bar of the step which pops up, select the icon with the curly braces which denotes Conditionals.
- In the Add Condition dialog box, select the element over which you wish to insert a conditional. In our case, let us select the element “Allow”.
- After making the selection, choose your desired option from the “Verify That” dropdown and after that, choose if you wish to skip this step or if you wish to execute this step in the same fashion as you recorded originally.
- After finishing up, simply click on the “Add Conditional” button inside this dialog box and voila! At time of execution, if there is no dialog box surfaced, Sofy will skip this step and move onto the next step to complete the test execution. And if the dialog box does appear, it will execute as was in the original recording.
- A yellow curly braces icon signifies that a conditional has been added to that step.
- When executing a test with conditionals, a yellow curly braces icon denotes that a conditional was applied to that step. For example, on step 2, there was a conditional applied where the original action was a click.
- Additionally, when you check Test Results located in the Runs & Report section, you will see the conditional step marked with a yellow tag. Moreover, in the details section of that step, you will find the conditions applied.
- If you skip a certain step, it will appear with the label "Step(s) Skipped". To view the step skipped, you can click on Show Me: