Variable-Based Conditional Actions

Updated by Kashif Hussain

As reusability becomes an important factor in scaling across a family of applications faster and more effectively, it may be beneficial to leverage this factor in your test authoring and execution. To that extent, we introduce Variable-Based Conditional Actions to help you reuse certain test cases across various flows and applications.

What is a Variable-Based Conditional Action?

A Conditional Action allows you to control whether an action such as click or an assert (such as a Component, Visual, or Variable assert) is executed or skipped based on a specified variable value.

How to utilize it?

  1. Log in to your Sofy account.
  2. Select Automation from the left navigation bar.
    Highlighting Automation Tab under main Sofy portal dashboard to access tests you have created.
  3. Search for and select the test where you would like to use conditional actions. In our case, we will be setting a conditional assert.
  4. Once you have selected the test case, you can left-click on an assertion step. As seen in the photo below, we will consider the highlighted assertion (test step # 8).

Highlighting an assert step on which we will be putting a condition.

  1. You will observe certain options to perform on the step, one of them being 'Set Condition On Step' as highlighted here

Highlighting the button to Set Condition on a test step.
  1. You will be directed to choose a test variable from the dropdown list.
Highlighting the dropdown where we may choose the variable we want to map to our condition
  1. After selecting from the variable, you will be prompted to enter the text along with a rule mapped between the variable and the text (i.e. should they match or be different).
Highlighting the prompt to enter the text along with a rule mapped between the variable and the text (i.e. should they match or be different).

  1. Before setting the conditional, you must specify what action should be taken upon the rule that you specified (i.e. whether the assert should execute or be skipped).
With all conditions set, you may review and add the condition.

  1. You may add your conditional assert and save your test. In this example, we have a dummy variable that has a String value and we have placed a condition on our assert that it should only be executed if the variable matches 'dummy'. Else, the assertion will be skipped. For more details on test variables and how to create and instantiate them, this article will guide you better on the basics.

Conditional actions are very handy in empowering reuse of test cases across applications that may vary in UI but adopt the same underlying functionality. Without needing to create separate test cases to address asserts, you can specify the actions you would like to use based on variables that you may keep globally static or may want to extract during test executions. The application for conditional actions reach beyond asserts and we will be happy to answer any queries or questions at customersupport@sofy.ai.


How did we do?