My Certifications Visit Documentation Mabl Home Mabl Product Portal Mabl Login

Conditional Steps within Tests

Summary

Summary

Learning targets 🧠
In this video, you will see how to: 

  • Define and describe conditionals
  • Add conditional steps to your tests
  • Review test output with conditionals

Review our documentation: Conditional Steps within Tests

 

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.

image1-Oct-08-2021-06-04-09-84-PM

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.

IF / ELSE / END

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.

ELSE IF

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.