Finding the correct element
Finding the correct element during test execution can present an interesting challenge. With dynamic content and often many similar elements on a page, it becomes all the more important to ensure that tests encapsulate the intention behind a particular action.
Mabl leverages a wide range of strategies to find the correct element based on the interactions recorded with your application and the various attributes we collect for each element. There are three key aspects to finding the correct element during test execution: timing, intention, and context.
In order to accurately locate the correct element, mabl needs to know if your application is in the correct state, why that particular element was selected, and if the context around the element is significant.
How find steps work in mabl
Mabl provides a range of configurations for finding elements during the test creation process. Understanding the differences between these strategies and when to use them can help you create more resilient tests.
- Standard find steps: When you record a step in mabl that interacts with an element, we collect information about the element's attributes. When the test is executed, mabl selects the best match based on which combination of attributes matches for each potential candidate and the history of finds for that element and similar elements.
- Configured find steps: When you configure a find for a step, you are able to specify which attributes are the most important. This allows mabl to tailor find strategies based on the intention behind the step.
- Configured finds for similar elements: When there are many similar elements on a page, mabl may prompt you to provide more context on why you selected a particular element. This information is used similarly to configured find steps.
- Wait and wait until steps: When your application needs time in order to reach the correct state, a wait or wait until step can be used. A wait step will wait for a static period of time before proceeding. A wait until step allows you to pick a specific element attribute, where the test will wait until the attribute is available on the page before proceeding.
- XPath and CSS selectors: When you are looking to target a specific element that is unlikely to change or if you would like additional control over a find step, XPath or CSS selectors can be used to create a custom find. However, it is important to note that custom finds do not have the ability to auto-heal.
Benefits of creating targeted find steps
There are a number of benefits to creating targeted find steps with Configure Find, including the following:
- Resiliency: As your application changes over time, mabl is more likely to continue finding the correct element, even if some of the attributes change.
- Auto-healing: By specifying what attributes are most important to you, mabl is able to accurately auto-heal.
- Versatility: By configuring find steps using data-driven variables, the intention behind a find step can be modified for a range of values.
Updated 4 months ago