Monday, July 29, 2024

Selenium XPath in detail

What is XPATH?
  • It is an XML path.
  • It is one of the locator types in selenium.
  • It uses path expression to navigate in XML documents and to identify a node or number of nodes.
  • XPath is used to handle complex and dynamic paths.
 
Types of XPATH in Selenium:
  1. Absolute XPath
  2. Relative XPath
 
What is Absolute XPath?
  • Absolute path starts from <HTML> tag.
  • It uses / ( forward slash ).
  • It is used to identify any element direct way by consider all the tag starts from <HTML> tag.
  • It is much more faster than "Relative xpath" as it holds the direct path to the target node/tag/element from start <Html> tag.
  • But we will mostly use this one if it holds a long string path and is difficult to maintain or handle. It is not a shortend path.
 
What is Relative XPath?
  • It uses //  ("forward double slash") .
  • It will consider any node/element/tag as a refernce point from where either we can traverse forard or reverse direction to identify target node/tag.
  • It is mostly used as we are considering any node as a reference node (stable node) from a DOM.

No comments:

Post a Comment