Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

What does it mean, if double slash is used 2 times in XPath? Suppose I'm using XPath like

//div[@id='add']//span[@id=addone']

1 Answer

0 votes
by (62.9k points)

If you'd have this.

//<div id='add'> <ul> <li> <span id='add one' /> </li> </ul> </div>

Then //div[@id='add']//span[@id='addone'] will result in the span because the second // means you look for any child relative to div[@id='add'] that is span[@id='add one'].

If you'd use one slash //div[@id='add']/span[@id='addone'] then of course you won't find it because then you look for a direct child and you'd have to use //div[@id='add']/ul/li/span[@id='addone']. So the second // is very useful in avoiding extra hierarchy in your Xpath.

Browse Categories

...