0% Complete


This lesson is made to help you understand how to work with Conditional Steps

Before taking this lesson

Make sure you are comfortable with the following lessons:

  • The mabl trainer basics including recording new steps and assertions.

Learning Objectives 🧠

By the end of this you will:

  • Understand what conditionals are
  • Understand how to use conditionals in mabl

It's learning time! 🤓

Why is this important?

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.

What is it?

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"

Getting started

Conditionals in mabl

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:


  • Element: If a checkbox is not checked, click it to set it as "checked"
  • Advanced Find: Using and XPath/CSS Selector, if a very specific element is present, then click it
  • JavaScript: Determine if the current browser is Internet Explorer. If it is, wait an extra 20 seconds.
  • Page URL: If the current URL ends in "/edit" then click the "Save" button
  • Cookie: If a specific cookie is not present, set the cookie and then refresh the page
  • Variable: If the email variable used to login contains "admin" then assert the admin settings button is present.


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.




Note: You can delete the ELSE step if you don't need to do anything if the condition is false.


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?

  • Conditionals allow you to situationally execute different steps in a test: "IF X is true then do Y, ELSE do Z"
  • In mabl, there are 4 different steps related to conditionals: If, Else, Else If, and End that combines to give control over how the test executes based on one or more states.


Was this helpful?

Take this 2 minute survey to let us know how we can make mablU better!