Creating resilient tests has become all the more important as development cycles become shorter and faster. With this rapid pace of development, testing has become a bottleneck for many teams. Tests created using legacy testing frameworks are often brittle and need to be fixed when an application changes significantly. Instead of dedicating time to create more resilient selectors, many automated testing tools have methods and strategies for adapting to these changes.
How mabl changes the equation
At mabl, our philosophy on test creation focuses on putting yourself in the user’s shoes. Mabl takes on the work of capturing these user paths so we can easily execute these tests for you. There are core tenants to this approach, such as finding the right element, understanding the context around a given action, and learning what is stable and dynamic in your application.
There’s one other key component of this process, and that is intention. By understanding what you are testing and why you are testing it, mabl can adapt to changes based on what is most important to you.
Working with mabl to understand intention
When capturing intention, there are a few ways to provide this information. When using our wait-until or configure find features, it is important to strike the right balance. Mabl will show you which attributes are available for a certain element, and ask you to provide information on why you selected a given element. Selecting only what is most important ensures that you do not over-constrain these steps. For example, even if the class name uniquely identifies the element, if it doesn’t determine some specific styling that is important for recognizing the element, then it would be better to choose a keyword or phrase in the innerText that helps identify just the right element and is less likely to change.
Configuring finds and wait-until steps
When selecting a timeout for these steps, the best practice is to use the longest time you would expect it to take for the element to appear. Mabl will only wait until it finds the correct element before proceeding with the test.
You also have the option to specify whether the step should auto-heal or fail if mabl is unable to find the matching element. Auto-healing will find the next best match within your application. However, if you always want to find the element that contains the text “Alpha, you can specify that the step should fail using the “Fail this step” option if that text is not found.
Working with tables and grids
Intention is especially vital in cases where there are many similar elements on the page, such as tables or grids. These instances are particularly challenging to identify why a given element was selected. For example, did you click the first edit button in this list because of the position, the status, or the id? As more items populate this table, mabl can continue finding the target element by utilizing this context.
Taking resiliency to the next level
Machine learning and auto-healing are only the beginning of resilient testing. Understanding intention results in tests that truly leverage both machine and human intelligence, require less maintenance, and evolve alongside your application. Interested in creating your own resilient tests with ease? Sign up for a free mabl account to get started.
Or to learn more about this topic, check out my full session from last week's Experience event: