What are the different types of XPath in Selenium?
The XPath is a query language for selecting nodes from an XML document. An XPath expression is a string that specifies the location of the nodes relative to their siblings, or more specifically, the location of elements relative to their parent element.
Here are the two main types of XPath in Selenium:
As the name indicates, absolute XPath contains the complete path from the root element to the desired element. It is ideal for storing XPath in a file which can then be used anytime later with any HTML page.
In relative XPath element is positioned relative to its normal position. It starts by referencing the element we want to locate relative to a particular location.
To get into details, please refer to the following XPath cheat sheet: