- Absolute XPath
Absolute XPaths starts with the root of the HTML pages.
Absolute XPaths are not advisable for most of the time due to following reasons
- Absolute XPaths are lengthier and hence they are not readable
- Absolute XPaths are brittle when minor structural changes are done to the web pages
Absolute XPaths shall be used only when a relative XPath cannot be constructed. (highly unlikely). Absolute XPaths tends to break as web pages/content is changed. Hence it is not recommended to use absolute XPath in Selenium.
Syntax: Absolute XPaths start with /html
2. Relative XPath
Relative XPaths is used for locating an element with respect to an element known as XPath. The element of your choice is referred relative to a known element.
Syntax: Relative XPaths are started with two forward slashes ‘//’.
Note: Absolute XPaths are faster than the relative XPaths
3. Exact XPath
Locating elements using their attributes, values and inner text of the elements.