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,320 points
4,467 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,490 points
2,312 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,190 points
1,795 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,190 points
34,197 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 20, 2018 in Selenium by Nabarupa
67,302 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
13,674 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
9,143 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
7,221 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,875 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
7,376 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
3,332 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