When you train a mobile test, the mabl Trainer collects attributes about each element you interact with to ensure that your tests target the correct element during execution. If your tests aren't targeting the correct element during Trainer replay or test execution, use the following checklist to troubleshoot the issue:
Add Configure Find
If the target element is very similar to other elements on the page, update the step to use Configure Find. With Configure Find, you can:
- Specify which element attributes mabl should look for
- Set a timeout to define how long mabl should look for the element.
Reselect the element
If you cannot target the correct element using the attributes specific in Configure Find, try reselecting an alternative target element that is more unique. For example, if your test fails to tap the correct button on the screen, there may be a child element within the button that contains a more unique attribute, such as text.
To reselect the target element for a test step, launch the test in the Trainer and take the following steps:
- Hover your mouse over the step that isn't targeting the correct element.
- Click on the edit pencil.
- Click on the Reselect button. The mabl Trainer adds an overlay to the application under test.
- Hover your mouse over elements in the application to view their attributes.
- Select an alternative element that has more unique attributes and accomplishes the same intended action.
- Click OK to update the target element for the step.
Reselecting an element
Talk to your developers
If you could not retrain the step with an unique alternative, ask your developers to make the element easier to target, such as providing resource IDs.
Adding unique attributes is a best practice for automated testing.
The debug view
When you talk to your developers about the challenges you’re facing when interacting with the target element, consider using the debug view in the mabl Trainer as a resource. The debug view is a diagnostic tool that you can use to understand target element attributes in isolation and in context. Learn more.
Enable "Find by XPath"
If mabl fails to identify the correct element and your developers cannot add more unique attributes to the elements, consider enabling "Find by XPath".
Unlike standard recorded steps, which use a range of strategies to target the correct element, "Find by XPath" identifies the target element only using XPath. If you enable "Find by XPath", keep in mind the following:
- The recorded XPath cannot be edited.
- "Find by XPath" is more brittle. If there are any changes in your application, the step may fail and you’ll have to retrain the interaction.
To enable "Find by XPath", take the following steps:
- Hover your mouse over the step that isn't targeting the correct element.
- Click on the edit pencil.
- Check the box for "Find by XPath"
- Click OK to update the step.