Feature Requests & Ideas

For bug reports and questions, please use the in-app chat or support@mabl.com.

For loop

As a test author, I want the option to enclose a set of steps/flows in a 'for' loop iterating over provided array of values or numeric range, so that I have a single source of truth for the repeated logic (therefore one place to make changes).

  • Lukas Linhart
  • Aug 8 2019
  • For Consideration
  • Attach files
  • Admin
    Anton Hristov commented
    08 Oct 03:08

    Can you please describe one or more scenarios for the app under test that you would like to handle with a loop? 

    This will help inform the potential design of loop capabilities in mabl.

  • Mark Russel Cruz commented
    09 Oct 19:08

    Hi Anton. One idea that will benefit us in our automation is to implement this loop function. 

     

    Scenario: I have this dropdown list that has multiple options. Whenever I choose an option, there is an error message that is always displayed/triggered. It requires a couple of seconds before it disappear if the selected list return items on it. if the selected list is empty, the error will not be hidden(See screen recording in the attachment).

     

    I'm thinking we can have a javascript snippet that will return the number of items on the list that will be passed to the loop or we can simply set the value using a number as suggested by Lukas. 

     

    Having an If Statement inside this loop will be good since I can directly assert an element(error) via mabl's built in assert or with a JS snippet.  When element is verified present, it will continue with the loop. We can also just add a break statement that will stop the loop when a certain condition is met. 

     

    We can discuss this on a call if it's not that clear. Thanks.

  • Mark Russel Cruz commented
    09 Oct 19:14

    Continuation on the comment:

     

    The reason I need the loop is, we are using this select function on different environment on different test data.

     

    Currently, the select option is choosing a random item inside the dropdown and we need to make sure that the selected option has items on it. The main goal is to have a reusable flow created that will select a random option in the dropdown but at the same time, we need to make sure that the selected list is not empty. Hence, we need to check/assert for the error message every time we need to randomly choose an item.

  • Lukas Linhart commented
    10 Oct 13:20

    I'd expect the for loop to resemble the one in python, please refer to the docs (the `else` clause is probably an overkill):

    https://docs.python.org/3/tutorial/controlflow.html#for-statements

    https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops

Copyright © 2019 mabl Inc. All rights reserved.