Adding Conditions to Test Cases

Updated by Aishwarya Rai

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.

For example:

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?

  1. Click on the Automation tab from the left panel on your Home Screen

  1. 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.

  1. Inside the Edit Test section, select the step over which you wish to insert a conditional. As an example, let us select Step 2.

  1. In the action bar of the step which pops up, select the icon with the curly braces which denotes Conditionals.

  1. 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”.

  1. 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.

  1. 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.
  2. A yellow curly braces icon signifies that a conditional has been added to that step.

  1. 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.
  2. 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.

  1. 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:

How did we do?