82
Locating Strategies- (By XPath)
- XPath is a language used for locating nodes in XML documents.
- XPath can be used as a substitute when you don’t have a suitable id or name attribute for the element you want to locate.
- XPath allows you to select individual elements, attributes, and some other part of XML documents for specifying location of a particular web element.
In WebDriver, the Java syntax for locating elements through XPath can be written as:
However, there are different ways of writing dynamic XPaths such as:
- Using Single Slash
- Using Double Slash
- Using Single Attribute
- Using Multiple Attribute
- Using AND
- Using OR
- Using contains()
- Using starts_with()
- Using text()
- Using last()
Next TopicWebDriver Locating Strategies