At our recent Experience event, the mabl community came together to share best practices, industry trends, and celebrate success in software testing. In the "Train Like A Pro” session, mabl Software Engineer Tamara Yu and Sales Engineer Andrew Horgan focused on how to harness the full power of the mabl Trainer, our low-code solution for easily creating robust automated tests.
Getting started
The foundation for any automation platform is training. With mabl, the easiest and most effective way to start training is to simply run through your app or website like a regular user. As you navigate, the mabl Trainer captures the attributes of each element and learns to track them over runs. Even if an element has few identifying attributes, mabl will attempt to find it by way of a more reliable ancestor element.
In this era of continuous delivery, applications are frequently updated to improve user experience. But if automated tests have to be updated each time, even for cosmetic changes, they become a bottleneck. To help teams maintain quality without sacrificing velocity, mabl monitors your application and automatically updates the tests as long as key functionalities aren’t affected. As a part of the auto-healing feature, mabl tracks various web elements over time by updating its knowledge of the page elements each time the test is run. Minor changes are recorded whenever the element is found, while more significant changes are saved only if the test passes. Steps that interact with the same element benefit from the same updates as the element changes. This ensures that tests are able to adapt as the product evolves without requiring manual maintenance.
Overcoming common challenges with test set-up
- Similar elements: A common challenge in creating reliable and resilient tests is identifying target elements amid other elements that share many of the same attributes, such as those in a list or grid. The mabl Trainer can automatically detect the presence of similar elements as a test is recorded and prompt users to provide more context to help disambiguate the true targets from other similar elements, typically by selecting and customizing key attributes to match.
- Dynamic data: When test data are dynamically generated per run, the page elements presenting the test data will change accordingly. Rather than relying on the default adaptation strategies to identify elements in each run, it's far more efficient to store test data in variables and specify criteria for finding elements in terms of those variables. Data-driven approaches like this give the Trainer a better understanding of how each test needs to be updated.
- Asynchronous timing: Modern web applications frequently rely on asynchronous events to update application states. If mabl sees that a page is updating, it will automatically wait until the page is stabilized, meaning the user doesn’t need to add any explicit or implicit wait in their tests. If this is insufficient or you anticipate a longer delay, you can add a wait-until step for the necessary element to appear.
- CSS/XPath selectors: when you need additional controls over specific finds, the mabl Trainer allows you to add CSS or XPath selectors. XPath in particular enables you to target an element with as much specificity as needed. When using XPath selectors, it is best to avoid full XPaths, which are often brittle. Instead, you can construct XPaths that select elements by key attributes and leverage axes such as ancestor and descendant. You can even embed variables in your XPaths, so the base XPath can be used to target different elements in a collection. Techniques like these can reduce the maintenance burden of steps that use these custom selectors.
Level up with customizations
As the end-to-end intelligent testing platform, mabl utilizes a powerful combination of quick-start tools as well as highly adaptable features that can be customized to fit an infinite number of testing needs. As you become familiar with the mabl Trainer, you’re able to take advantage of its unique capabilities with flows, JavaScript snippets, and APIs.
Flows are a popular mabl feature designed to speed up test creation and simplify test maintenance. They’re common sequences of steps that can be saved and inserted into any test with any combination of unique steps and other reusable flows, making it much easier to create routine tests and increasing test coverage of popular features or pages. Flows also reduce the amount of maintenance required as mabl will track where each flow is used, and update each test as the base flow evolves.
Similar to functions in many programming languages, flows can be parameterized; that is, you can pass input parameters to be used inside a particular instance of the flow. All instances of the flow contain the same variables, but each instance of the flow may have different inputs. This greatly expands the utility of a flow beyond a predefined set of steps.
For those scenarios that require highly custom logic, mabl provides JavaScript support. You can execute custom JavaScript in the browser as part of a test. You can also save the script as a snippet that can be reused across tests. You can even store the output of a custom JavaScript in a variable that can be referenced later in the test. Before writing your own scripts, be sure to check out the set of user contributed JavaScript snippets publicly available in mabl GitHub to see if there already is one that fits your needs. One example of a publicly available snippet generates a formatted date string and uses that to select dates in a datepicker component. The sky is really the limit on what you can do with JS snippets.
End-to-end API test steps are powerful tools to augment and streamline your browser functional tests. You can add API calls to your test to create authorization tokens, stage test data needed to exercise certain front-end features, validate the back-end operations of a front-end interaction, and more.
In addition to API steps, mabl provides the ability to test emails and PDFs which allows your functional tests to cover the end-to-end workflows of your applications. With mabl, you can generate temporary email addresses to receive emails, open the emails to validate content as well as extract data. You’re also able to do the same with PDFs, greatly expanding test capabilities and ensuring that all content formats can be validated.
With these features combined, you’re ready to unleash fully data-driven, end-to-end testing strategy with less time spent on test creation and maintenance.
A sneak peek to the road ahead
As we head into 2021, our team will be putting the finishing touches on building out new ways to make intelligent testing easy and accessible. Stay tuned for some exciting new enhancements to how users will create and maintain tests; we’ll be sharing more shortly after the holidays. In the meantime, take a look at the video below if you want to see Tamara and Andrew’s full session from Experience 2020.
Ready to see mabl in action? Check out the free trial today!