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,280 points
1,354 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,440 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,350 points
402 views
0 votes
1 answer

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

It is not necessary that every element ...READ MORE

answered Jun 1, 2018 in Selenium by Vinita
• 220 points
257 views
0 votes
1 answer

Check that the element is clickable or not in Selenium WebDriver

Use Selenium Waits: WebDriverWait ...READ MORE

answered Jun 12, 2018 in Selenium by Meci Matt
• 9,440 points
11,691 views
0 votes
1 answer

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
3,668 views
0 votes
1 answer

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,430 points
1,193 views
0 votes
1 answer
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,510 points
1,277 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,510 points
1,036 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,440 points
1,573 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,440 points
43 views