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

I'm writing a Selenium test case. And here's the XPath expression I use to match all 'Modify' buttons within a data table.


My question is, how can I visit the matched node sets by index? I've tried with



//img[@title='Modify' and position() = i]

But neither works... I also tried with the XPath checker(One firefox extension). There's a total of 13 matches found, then I have totally no idea how am I gonna select one of them.. Or does XPath support specified a selection of nodes which are not under the same parent node?

1 Answer

0 votes
by (50.2k points)

To select a specified node within the XPath node use this 


This line means all someName elements in the document those are the third someName child of their parent.

There may be a chance of having many elements

If you need exactly third someName element use this


Let me explain [] has more priority than //  and one more thing put all expressions of this type //someName in brackets when you need to specify a node of your selected node-list.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s automation testing certification!

Browse Categories