My Certifications Visit Documentation Mabl Home Mabl Product Portal Mabl Login

Looping

Summary

Summary

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

  • Define and describe looping
  • Add looped steps to your test
  • Maintain tests easier with looping

Review our documentation: Looping

 

Why is this important?

Looping steps is an important part of automating tests, because they can adapt to changes in your application, automate repetitive tasks with dynamic iterations (number of times to loop) and reduce test maintenance time - all without needing to write a single line of code.

What is it?

  • Looping is a no-code feature that enables you to automate repetitive tasks and set either static or dynamic iterations.
  • Why would I need to use Looping?
    • Skip several months ahead with a date-picker
    • Iterate through a drop down and assert everything expected is showing
    • Loop through radio button options and submit, to assert on a successful submission of each option
    • Browse search results until you find a specific item

Getting started

How to perform Looping

  1. In the Trainer, click the purple + sign at the bottom and either click Add flow under the “Recommended” section, or scroll down until you see “Loops”
  2. You’ll see “Create Flow” at the top of the Trainer - don’t worry! You’re in the right place :)
  3. Enter a name for the Flow
    (mabl naming convention best practices)
  4. Select “Looping” under the “Create Flow” banner at the top of the Trainer
  5. You’ll be presented with three options:
    1. Run once:
      1.  This will only run the Loop one time, which means you’re creating a basic Flow
    2. Loop using a fixed number:
      1. If the number of items/actions you need to loop through will not change, use this option to input a static number and mabl will iterate that many times each time the loop is executed
    3. Loop using a variable:
      1. If the number of items you want to loop through may change in each test run, select a variable to specify the number of times to loop. This option enables you to provide the number via a DataTable, API Step or from extracting the value from an element and storing it as a variable.
      2. For example: if your application has a search feature that may present varying results (cart items, list items, etc.), you can extract the number of pages, store that value as a variable and use that as the “Number of times to loop”
      3. Pro-tip: if running using a variable, a Conditional step may be added to break out of the loop early by specifying a different number in the conditional IF statement
  6. Record the action you’d like mabl to loop through
  7. If targeting the “nth” instance of a CSS or XPath element, using the run.loop_index is a useful option to help loop through the elements in order.