0% Complete

Introduction

Before this lessons someone should already:

  • Have gone through “mabl Application Introduction” lesson and understand the fundamentals of the mabl application.

Learning Objectives

By the end of this you will:

  • Know how and when to leverage Looping
  • Understand how Looping benefits your tests and aids with test maintenance

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:
      • This will only run the Loop one time, which means you’re creating a basic Flow
    2. Loop using a fixed number:
      • 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:
      • 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.
      • 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”
      • Pro-tip: if running using a variable, a Conditional step may be added to break out of the loop early be specifying a different number in the conditional IF statement
  6. Record the action you’d like mabl to loop through
    • Add assertions if applicable
  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.

Recap

Reflect

What did we learn?

  • How and when to use looping and how it can help save time on test maintenance

Connect

How is it related to what you know and are doing?

  • Looping is another way that mabl can automate tasks you might have had to update or change when your app was updated or changed

Apply

How to use this going forward?

  • Think about repetitive tasks that may benefit from looping:
    • Skip ahead to a date in the future in a calendar
    • Clean up data created during the test run
    • Iterate through a dynamic list of search results until the desired item is found

Feedback

Was this helpful?

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