Absolute and Relative XPath
Explore the concepts of absolute and relative XPath used in Selenium UI testing. Understand how absolute XPath starts from the root while relative XPath begins anywhere in the DOM. Learn why relative XPath is more robust and less prone to breakage due to structural changes in the webpage. This lesson helps you write effective XPath locators that maintain stability in automated tests.
We'll cover the following...
We'll cover the following...
What is an absolute and relative XPath?
In an absolute XPath, you traverse from the top of the hierarchy, say html or body node, until the target node in the DOM.
In a relative XPath, as the name suggests, we can start locating the element from anywhere in the hierarchy tree, including the same exact node.
Let’s look at the ...