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.
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/a
Did you notice the difference between the Absolute and Relative xpaths?
Absolute xpath: /html/body/div/div/div/footer/section/div/ul/li/a
Relative xpath: //*[@id=’social-media’]/ul/li/a
Here , I am not getting how you written Relative Xpath ?
First you have to inspect the RSS feed with firebug from the demo site “http://store.demoqa.com/”
and then write the relative xpath manually.
Please refer to attached screenshot.
The RSS feed has a div id as “social media”
ul is the first child of the div id hence //*[@id=’social-media’]/ul
as we are referring to the third “li” tag hence “li”
ans finally inside li we are referring to “a” tag hence the final relative path goes like “//*[@id=’social-media’]/ul/li/a”