Feature Requests & Ideas

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

Ability to select a random object from the list of objects identified through configure find

I want to be able to select one of the matching elements at random, but at the same time don't want to use the selectors (CSS or XPath) as using them will disable the auto-heal feature.

Right now, Mabl provides two options either to select the first matching element or the last one through the configure find.

The use case is to select one of the available items at random.

e.g., Selecting one of the nonstop flights from the available list at random. That way we can ensure we are not overbooking the first available flight and at the same time we would be able to test if the flow is working fine for all the available flights.

That will also increase the probability of passing the test if it did not pass in the first attempt due to some issues in the first available flight.

That will help us to make sure that the customer would be able to do the booking for any available flights without any issues.

  • Guest
  • Mar 10 2021
  • For Consideration
  • Attach files
  • Anton Hristov commented
    11 Mar, 2021 09:05pm

    Thank you for the detailed feedback request.

    There are two ways you can approach this test case with the current capabilities:

    1) Use a custom find (CSS/Xpath) to target the Nth child element or an element with a given id: You can create a variable that uses an expression to set a random value between a given range such as 1 to 10 like this {{randomInt(1, 10)}} . You can also get a dynamic count of total available flights with the find step option for "Number of available elements" in the mabl Trainer. Then you can create a variable randomNumber to store that random number using a string template like {{randomInt(1, @numEntries)}}

    A CSS query will looks something like this .MuiFormGroup-root > label:nth-child({{@randomItem}}) Though, it will depend on how your page DOM is structured.

    Feel free to contact our support via in-app chat if you need help creating the above selectors with random options.

    2) Use conditional logic instead of random selection: in the test, check if flight is overbooked and return to the beginning of the flight search where, I assume, the first flight option will not include already booked flights. You can introduce some delay in the test (e.g. 10 seconds) to ensure that already booked flights are processed and don't appear in the search.

    We are also working on an option that will let you configure a native find, which can auto-heal, to specify an ordinal position for a target element within a repeating set of elements. We plan to make this option available in the near future.

Copyright © 2021 mabl Inc. All rights reserved.