<<Previous Post << Complete Tutorial>> Next Post>>
In the previous articles, I have explained What is an XPath? and the Hierarchy of HTML Source Code
In this article, I am going to explain the types of XPath Expressions.
Let’s get started.
Types of XPath Expressions
The following are the two types of XPath Expressions:
- Absolute XPath Expression
- Relative XPath Expression
What is an Absolute XPath Expression?
Absolute XPath Expressions has the Complete Path from the Root element and is used for locating the UI elements on the Web Pages.
Example: /html/body/p[1]
In the above example, the root element is /html and the complete path starts from root element /html and goes down the till it reaches p tag
Note: The above example will be explained in detail in the upcoming articles, till then understand it at a high level.
What is a Relative XPath Expression?
Relative XPath Expression is nothing but the direct or shortcut path and is used for locating the UI elements on the Web Pages.
Example: //p[1]
In the above example, we have used a shortcut or direct path to locate the UI element on the web page.
Note: The above example will be explained in detail in the upcoming articles, till then understand it at a high level.
As you now understood the different types of XPath Expressions and their differences, I will explain the detailed way of constructing both types in a step by step manner in the upcoming articles.
Next Steps:
- > To learn more about Selenium, continue to the next post (Click on Next Post link below)
- > Check complete Selenium Tutorial Contents here (Click here)
Please leave your questions/comments/feedback below.
Happy Learning ?
On a mission to contribute to the Software Testing Community in all possible ways.
<<Previous Post << Complete Tutorial>> Next Post>>