The Significance of Using Xpath In QA Testing

Posted By : Pooja Kumari | 26-May-2020

Xpath is the syntax or language to find an element on the web page. In this blog post, we'll explore the significance of using Xpath in QA testing.


Finding an element is one of the most difficult parts. If you are not able to find the elements by the easily available approaches like ID, CLASS, NAME, LINK, and TAGNAME, then Xpth is one of the best methods to rescue you from this problem in selenium. We can say that Xpath is the syntax or language to find an element on the web page.


Standard syntax of creating Xpath is given below:



  • // :Select current node.
  • Tagname: Tagname of the particular node.
  • @ :Select attribute.
  • Attribute: Attribute name of the node.         
  • Value: Value of the attribute.


Types of X-path

1. Absolute Xpath

2. Relative Xpath


Absolute Xpath

In case of an absolute Xpath, it starts with a single '/ ', which means you can select the element from the root node. One of the biggest disadvantages of using that is, whenever during the development period, any changes will be made in the Xpath then, Xpath will become invalid which leads to script failure.


For example: 




In the above example in selenium, if any of the tag names like section or any of the division changes then, Xpath will become invalid and it will lead to script failure.


Relative Xpath

In the case of relative Xpath, It starts with a double forward-slash(//), it means, it can search the elements anywhere on the webpage.


For example:



In the above example in Selenium, we are searching from the current node with tag name input having attribute as the name with value as email.


Xpath Function

In some cases, when the elements having the same attributes, names, or having more than one button with the same name and same Id's, then it becomes challenging to identify the particular object on the web page using selenium, then Xpath function comes to solve this problem.


Types of Xpath functions are:

1. contains()

2. starts-with()

3. text()

Related Tags

About Author

Author Image
Pooja Kumari

Pooja is QA engineer . She has knowledge of manual testing and SQL. And keen to learn new things.

Request for Proposal

Name is required

Comment is required

Sending message..