Home » Selenium WebDriver Locating Strategies By XPath

Selenium WebDriver Locating Strategies By XPath

by Online Tutorials Library

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:

  1. Using Single Slash
  2. Using Double Slash
  3. Using Single Attribute
  4. Using Multiple Attribute
  5. Using AND
  6. Using OR
  7. Using contains()
  8. Using starts_with()
  9. Using text()
  10. Using last()

You may also like