Using conditional steps

Within the mabl Trainer, you can add conditional steps inside tests to run groups of steps or flows conditionally. Available conditional steps include the following:

Conditionals can include any number of steps or flows and can also be used within a reusable flow. This guide provides an overview of adding and running conditional steps in browser tests.

Adding conditionals

IF steps

  1. While in the mabl Trainer, click the plus button at the bottom of the Trainer window to add a step.
  2. Click on "Conditionals." A dropdown will appear with available conditional steps.
  3. Select "Insert IF."
  4. Choose a condition to base the statement on:
296296

Once the IF statement is added, record the test steps that you want to add to the IF condition.

The mabl Trainer will automatically add an ELSE and an END step.

  • The ELSE block will run in the event that the IF statement is false. If you do not need to run steps for an ELSE scenario, you may delete this step.
  • The END step is required. If you delete it, you will get a warning in the Trainer that the conditional statement has no END step.

ELSE IF steps

If you want to check for multiple cases within the same conditional block, you can add an ELSE IF step: `+ (Add steps) > Conditionals > Insert ELSE IF. Similar to IF steps, ELSE IF steps prompt you to choose a condition to base the step on.

After creating the ELSE IF step, record the test steps that you would like to execute if this condition is met.

ELSE steps

Steps within an ELSE step run in the event that the conditions of an IF or ELSE step are false. If you do not need to run steps for an else scenario, you can leave it empty or delete the step. You can always add a new one, if needed: + (Add steps) > Conditionals > Insert ELSE.

END steps

The END step is required for a conditional block. If you delete it, you will get a warning in the Trainer that the conditional statement has no END step. If you need to add a new one: `+ (Add steps) > Conditionals > Insert END.

Running conditional steps

If a certain condition is met, the steps within that conditional statement run. Steps within other conditional statement are skipped.

Skipped steps

  • If an IF step evaluates to false, the steps within the IF condition are skipped.
  • If an IF ELSE step evaluates to false or follows an IF condition that was true, the steps within the IF ELSE condition are skipped.
  • If an IF or IF ELSE step evaluates to true, the steps within an ELSE condition are skipped.