This article explains mabl's options for creating reusable sets of test steps with flows, including parameterized flows and loops.
Some browser and mobile testing scenarios may require recording the same set of steps to get your application in a specific state, such as logging into an application, adding an item to a shopping cart, or navigating to a specific page or screen. To avoid spending extra time and effort maintaining similar test steps across different tests, use flows.
Flows are common sequences of test steps that you can insert into any browser or mobile test and edit in bulk when changes occur.
Example of a login flow
When you save a browser or mobile test with a new flow, mabl saves the flow to your workspace: Tests > Flows. You can import flows into other tests and even insert the same flow multiple times in one test.
Mabl supports reusable flows for browser and mobile. If you save a flow in a browser test, you can reuse that flow in other browser tests. If you save a flow in a mobile test, you can reuse that flow in other mobile tests on the same platform: Android or iOS.
Mabl does not support reusable flows for API tests. While API tests include flow-level settings for authentication, pre-request, and post-request scripts, it is not possible to create a reusable flow for an API test.
The flows page
When you save changes to a flow, the changes automatically propagate to all tests containing the flow. To manage different versions of a flow, use branches.
If you want to scope variables to a single flow or reuse a flow with different variables, add flow parameters. Flow parameters are variables that only exist inside a flow. Their values may be a static string or number or another variable, including variables from a DataTable.
If you reference another variable, use mabl variable syntax. For example, the variable
Without parameters, a flow does the same thing every time. With parameters, you can control the data used in the flow. If you are familiar with some common programming languages, you can think of flows as functions and parameters as input for one instance of the flow.
For example, if you create a flow that searches for a person based on their phone number, you can add parameters to search for a phone number that you created earlier in the test.
Example of a parameterized flow
Defaults and overrides
When you create flow parameters, you must add default values. Mabl uses the default flow parameters unless you provide overrides.
When you override a default parameter value, mabl only applies the override value to that instance of the flow.
A loop is a flow that repeats itself using a fixed number or variable. Loops are useful when you want to set up a sequence of steps to repeat based on real data in your application. For example:
- Asserting that a constant element appears across multiple pages
- Asserting that all elements of a dropdown appear
- Browsing through a list of search results until the correct item appears
Loops don't require any code, making it easier to test complex user journeys that cover more of your application.
To determine the number of times a loop runs dynamically, configure the flow to loop using a variable. For example, if you want to confirm that every page of a search result includes a constant element, but the total number of pages may be different on each run, you can take the following steps:
- Create a variable that stores the total number of pages.
- Create a flow and configure the flow to loop using the page variable number.
- In the flow, assert on the constant element and click on the "next page" button.
Playing loops in the Trainer
When replaying loops within the mabl Trainer, mabl tries to resume playing the loop at the current index, even if you stopped the loop partway through. You may also select the iteration to replay using the loop dropdown.
Replaying loops in the Trainer
To learn more about flows, parameters, and loops, check out the following articles: