Understanding the basics
A typical UI (whether for desktop, mobile, or web application) is organized into series of containers nested one inside the other. To locate a given UI object, an automated test uses attributes such as the object ID, class, name, and the path to locating it within its container. Some locators are inherently more stable than others.
Watch the video below for a demonstration identifying UI objects in Ranorex Spy. As you watch, notice that Ranorex Spy includes wildcards (*/*) in the path to an object, which increases the reliability of the selector. If there is a change in the hierarchy of the application, the automated test will still be able to find the UI element.
Building stable locators
The following principles help ensure that your automated tests can find your UI objects reliably.
Avoid coordinate-based recognition
Avoid image-based recognition
Avoid using dynamic IDs
Use the shortest path
Additional best practices
The following practices will help make your UI tests more resilient and reduce maintenance.
Use an object repository
Get your developers involved
Troubleshooting object recognition
Even when using stable locators, object recognition can sometimes fail. Below are tips to help you resolve issues with object recognition.
Invisible UI elements
Snapshots
Related Posts:
How To Improve Software Quality and Why It Matters
Software quality is a core concern for all software developers, and it encompasses more than just the code. Here’s how to improve software quality in nine ways.
How To Reduce Testing Times
This is a helpful guide on how to reduce software testing times and the benefits of doing so. Check out these four tips to achieve more time-efficient testing.
What Is Behavior Driven Development?
This comprehensive guide covers the ins and outs of behavior-driven development. Learn all there is to know here, including benefits, challenges, and more.