This lesson is made to help you understand how to work with Conditional Steps
Make sure you are comfortable with the following lessons:
It's learning time! 🤓
Being able to test different permutations of test scenarios makes individual tests more powerful and efficient, allowing you to have fewer tests that do more.
A conditional step allows for a test to execute different steps in different situations.
Take a look at the image. In this situation, the test will either refresh the page or click on an element if it is present.
While there are more complex ways to use conditionals, this is a really good simple example.
"IF X is true then do Y, ELSE do Z"
To add conditional steps to a mabl test, go to the list of step types, click "Conditional", and then click on the INSERT IF option.
In this menu, you will see a number of different options for creating conditionals. Here are some examples of ways you might use each option:
Once you decide on what your conditional will be based on, 3 steps will be added to your test.
The first step is an IF step. This will define the condition your test will check.
The second step is an ELSE step. If the condition is true then all steps between the IF and the ELSE step will be executed.
The last step added is an END step. If the condition is false then all steps between the ELSE and the END step will be executed.
An Else If step is a step that allows you to add an additional path that a test can take if the first conditional statement is false.
Let's say that we have a random number generator that generates a number between 0 and 100.
For our use case, we want it to generate a number that is more than 50 and that ends with a 5.
I order to do that, if those conditions are not met we should generate a new number.
Take a look at the image to see how to handle this using an Else If step. In the example, step 5 would NOT run but step 7 would.
Powerful stuff, right?
What did we learn?
Take this 2 minute survey to let us know how we can make mablU better!