The standards to use for defining locators will vary from AUT to AUT. In a perfect world, all browser and mobile pages would have a unique ID assigned to each element in the application, and users would just create a static locator using those IDs. Unfortunately, it is not a perfect world.
However, there are some common best practices that users can follow to ensure the framework is as efficient as possible.
Let's take a look at each type of locator.
The locator types can be divided up into three distinct categories: simple, CSS, and XPath. Let's discuss each type here.
Simple locators are those that have one attribute in the browser DOM or mobile page that makes them unique from other elements, and does not include any hierarchy such as a parent, child, sibling, or descendant. This includes id
, name
, className
, tagName
, linkText
, and partialLinkText
.
So for example, when we looked at the Google Mail login page...