Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
14.7k views
by The go-to Tester (324 points)
closed by
What is the difference between a single and double slash used in XPath?
closed with the note: Got it, sir

1 Answer

1 like 0 dislike
by The go-to Tester (181 points)
selected by
 
Best answer

Usually absolute xpath starts with single slash. When use use absolute xpath, you will be covering whole path to the element.

Relative xpath starts with double slash. In that case you will be first finding unique parent node and path from there to the element.

 

E.g. If you want to identify logo if this page, there are two ways you can do that.

Absolute xpath = /html/body/div[2]/div[1]/div[1]/a

Relative xpath = //div[class="qa-logo"]/a

Hope that helps!


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...