RE: How to write Relative Xpath

To choose the relative xpath, it is advisable to look for the recent Id attribute. Look below at the HTML code of the above screen shot.Locators-4

You can see the recent or last Id produced is ‘footer_nav‘. This id would be appropriate in this case, so a quality xpath will look like this:  //*[@id=’social-media’]/ul/li[3]/a

Did you notice the difference between the Absolute and Relative xpaths?

Absolute xpath: /html/body/div[2]/div/div/footer/section[3]/div/ul/li[3]/a

Relative xpath: //*[@id=’social-media’]/ul/li[3]/a

Here , I am not getting how you written Relative Xpath ?

Murali Train Asked on December 17, 2014 in Selenium WebDriver.
Add Comment
4 Answers

The single quotes mentioned in the above relative path is the issue.

manually enter the single quotes again and it works.

Supporter Answered on December 17, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.