Can multiple web elements have 1 xpath | Selenium C# Forum
Shalvi Posted on 05/10/2022

Hi Team,

The video says Multiple elements can have same xpath, but in he explanation example I can see that for Buy Now div is changing like div[1], div[2]

Please can you help me with the same

Raj Kishore Replied on 06/10/2022

There is always a chance to have multiple elements with same xpath. Example: table/tbody/tr

In a table, we have multiple rows with same xpath. To extract each row into a list we need to identify them by iterating over the tr tags with there index.








Similarly for 'Buy Now' there can be mutliple elements with same xpath but based on there indexes selenium can identify the precise button among them.

Shalvi Replied on 09/10/2022

Okay Raj, Thank you for the response