There are many complex scenarios that you can now reliably cover with automated testing. If you want to learn more about looping in mabl, register for our webinar this Friday, February 14.
As people, we often follow the same steps every day. Whether it’s the path we take on the way to work or our nightly bedtime routine, these loops continue and adapt to our everyday changes. At mabl, we believe your automated tests should too.
To us, the best tests are the ones that adapt to changes in your application. Your tests shouldn’t break because you’ve added a new feature to your app, nor should it fail to test a portion of your app because it never selects the newly added options in a dropdown. By setting up a set of steps that repeat based on real data in your application (such as the number of choices in a dropdown or count of a specific element on the page), you can more easily create complex tests that cover more of your application, are more robust, and are faster to create and maintain.
We’re excited to announce support for looping of steps within mabl to enable you to test more complex user journeys in your application - with no coding necessary.
Say you’re testing an e-commerce website with a banner that appears above every page of your search results. Verifying that the banner appears above every page of those same results can be tricky to automate. In this case, simply looping a static number of times would easily break your tests if a page is added or removed. Instead, create a loop based on the number of available pages during that run of the test, and you’ll never need to edit that test again!
Any reusable flow in mabl can be statically set to loop one time to 100 times, or dynamically, based on the number of times an element appears on the page - and more. Since you can store steps into reusable segments (flows), the same flow can be used multiple times in multiple tests. Not only will you never have to maintain your tests, but you won’t have to rewrite your steps either - saving you even more time!
Inserting a flow into a test
Need to change what steps are looped across your tests? Just update one flow and mabl does the rest. All your tests will be automatically updated to use your newly updated flow. This means no more tracking down every test that uses those steps and updating each by hand.
Test loops are particularly useful when:
- Skipping six months ahead in a date-picker element
- Asserting that all elements in a dropdown are shown
- Cleaning up test data created earlier in the test or deployment
- Browsing through a list of results until the correct item appears
- Asserting that a constant element appears across multiple pages
To create a loop within mabl, you’ll first need to determine the number of times you want to loop. This can be a static number, like 5, or a variable value. For example, the variable can be based on a number on the page, or the number of times an element appears on the page.
When using a variable, be sure to define it before you use it in a looping flow. Once you have established the number of times you would like to loop, add the looping functionality to the flow and switch to the “Looping” tab. From here, select the variable or input the number of times you’d like to loop.
Once the loop is configured, just add your test steps to the flow like you normally would! If you’d like the loop to stop once you’ve found your element, add a conditional statement that sets the variable you used to 0, or sets the current value of run.loop_index to 0. This will end the flow and continue on to the remaining steps in the test.
Reusable flows and looping are available to all customers and trials in mabl, so try it out for yourself! Create a free account at app.mabl.com/signup.
There are many complex scenarios that you can now reliably cover with automated testing. If you want to learn more about looping in mabl, register for our webinar this Friday, February 14. Register here.