Variable-Based Conditional Actions
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?
- Log in to your Sofy account.
- Select Automation from the left navigation bar.
- Search for and select the test where you would like to use conditional actions. In our case, we will be setting a conditional assert.
- 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).
- You will observe certain options to perform on the step, one of them being 'Set Condition On Step' as highlighted here
- You will be directed to choose a test variable from the dropdown list.
- 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).
- 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).
- 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.