What is Xpath and what are the types of it in Selenium Webdriver

0 votes
What us Xpath in selenium webdriver and what are the types of it?
May 8, 2019 in Selenium by Piyush
5,051 views

1 answer to this question.

0 votes

Hi Piyush, XPath is defined as XML pathIt is a syntax or language for finding any element on the web page using XML path expression. XPath is used to find the location of any element on a webpage using HTML DOM structure. XPath contains the path of the element situated at the web page. Standard syntax for creating XPath is.

Xpath=//tagname[@attribute='value']      where,
  • // : Select current node.

  • Tagname: Tagname of the particular node.

  • @: Select attribute.

  • Attribute: Attribute name of the node.

  • Value: Value of the attribute.

Now, there are 2 types of Xpaths:

1. Absolute XPath: It is the direct way to find the element, but the disadvantage of the absolute XPath is that if there are any changes made in the path of the element then that XPath gets failed. For eg. ​

html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b

2. Relative Xpath: For Relative Xpath the path starts from the middle of the HTML DOM structure. It starts with the double forward slash (//), which means it can search the element anywhere at the webpage. For eg.

 //*[@class='featured-box']//*[text()='Testing']

answered May 9, 2019 by Pratibha
• 3,690 points

Related Questions In Selenium

0 votes
1 answer

What are locators in Selenium and what are the different types of it?

Hi Divya, in Selenium Locators define an ...READ MORE

answered May 7, 2019 in Selenium by Abha
• 28,140 points
2,345 views
0 votes
1 answer

What is a Selenium framework and what are the benefits of it?

Hi Disha, Selenium framework is a code structure ...READ MORE

answered May 13, 2019 in Selenium by Abha
• 28,140 points
906 views
0 votes
1 answer

What are the different types of TestNG listeners in Selenium Webdriver?

Hello Jagrati, some of the TestNG listeners ...READ MORE

answered Jun 12, 2019 in Selenium by Anvi
• 14,150 points
1,607 views
0 votes
1 answer

What are the main types of regex quantifiers used in Selenium Webdriver?

Hi Andrew, some of the regex quantifiers ...READ MORE

answered Jun 26, 2019 in Selenium by Abha
• 28,140 points
5,054 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,578 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,559 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,606 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,506 views
0 votes
1 answer

What is Robot Class in selenium webdriver and why it is used?

Hello Akanksha, Robot Class is used for those ...READ MORE

answered May 9, 2019 in Selenium by Pratibha
• 3,690 points
1,810 views
0 votes
1 answer

What is the difference between WebDriver and RemoteWebdriver in Selenium?

Hey Ishan, the difference between Webdriver and ...READ MORE

answered May 10, 2019 in Selenium by Pratibha
• 3,690 points
10,315 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP