Finally, the XPath query is the most versatile type of locator, since it is bidirectional by nature, but it is also the slowest locator type to use (CSS locators can only reference elements in one direction, but are faster). Here is the simple XPath locator for this field:
@FindBy(xpath = "//input[@id='identifierId']")
protected M email;
There are whole sets of rules and techniques for building CSS and XPath locators; some of these will be discussed in the next section.
- The Wikipedia definition and ruleset for the XPath query language is located at https://en.wikipedia.org/wiki/XPath
- The Oracle documentation for the XPath query language is located at https://docs.oracle.com/cd/E18442_01/doc.651/e18053/xpath.htm
- There is an XPath tutorial located at https://www.w3schools.com/xml/xpath_syntax.asp
- There is a CSS set of rules located at https://www.w3schools.com/cssref/css_selectors.asp