Which is preferred more in Selenium Absolute or Relative XPath

0 votes

Which is preferred most in Selenium automation testing, Absolute XPath or Relative XPath

Apr 20, 2018 in Selenium by Martin
• 4,340 points
2,581 views

1 answer to this question.

0 votes
  • Absolute XPath is the direct way to find an element on the Web Page.
  • Characteristic of Absolute XPath is that it begins with a single forward slash(/) as shown in the syntax below:
  • /html/bodr/div[1]/div[3]/div/div/div/div/div[2]/form/table/tbody/tr[2]/td/input[@id= 'email']
  • In Relative XPath, the path does not start from the root of the HTML structure
  • It starts with the double forward slash (//), which means it can search the element throughout the webpage
  • There is no need to write long XPath as in Absolute XPath
  • The syntax of relative XPath is:-
  • //table[@role='presentation']/tbody/tr[2]/td/input[@id='email’]

Relative XPath is preferred more than Absolute XPath

answered Apr 20, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

Which is better CSS or Xpath? Considering performance and cross browser testing

According to css has better performance compared ...READ MORE

answered Apr 17, 2018 in Selenium by Shubham
• 13,480 points
1,041 views
0 votes
2 answers

what is the need of xpath when you have attributes like id ,class,name in selenium?

some of the controls not have id ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,010 points
776 views
0 votes
2 answers

Check that the element is clickable or not in Selenium WebDriver

Hi , you want to know only is ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,010 points
25,045 views
0 votes
3 answers

What is the difference between relative and absolute XPath?

Absolute Xpath: It contains the complete path ...READ MORE

answered Dec 19, 2018 in Selenium by Nabarupa
28,084 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,520 points
5,050 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,010 points
5,798 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,890 points
3,561 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 2, 2020 in Selenium by Sri
• 3,010 points
4,293 views
0 votes
1 answer

XPath for the elements with no ID or Name in Selenium Webdriver

Use like this or similar to this: //div[@id="top-level-menu-item-3"]/div[@class="filter-label"] //div[@id="top-level-menu1"] ...READ MORE

answered Apr 17, 2018 in Selenium by Meci Matt
• 9,460 points
3,640 views
0 votes
1 answer

Which programming language is highly used in Selenium

Java is most widely used programming language ...READ MORE

answered Apr 25, 2018 in Selenium by Meci Matt
• 9,460 points
377 views