Mobile Locator Strategies
Locator strategy directly affects test stability and performance.
- Poor locator -> Flaky tests
- Good locator -> Stable tests
Recommended Order
Accessibility ID (Best Practice)
- Fast
- Stable
- Cross-platform
ID / Resource ID
- Very reliable for Android
XPath (Last Resort)
- Slow
- Fragile
- Breaks easily after UI changes
Best Practice
- Ask developers to add accessibility IDs
- Avoid XPath whenever possible
This dramatically reduces flaky tests.