Two objects with the same XPATH and attributes

I have 2 objects with same xpath and attributes.
Whenever I am trying to execute the scenario, it is always pointing to the first object.
How to differentiate?

More details, please…

I have two fields for which I can mark 'Yes, or ‘No’ like:
Field1 : Yes/No
Field2: Yes/No
I did recording and when trying to execute the script, it is identifying only 1st object.
Both the objects have same xpath and properties.
I want to click on ‘Yes’ for the 1st field and than on ‘Yes’ for the 2nd field.

Obviously, we have to find an unique pathway to each element. Are you familiar with xpath attributes, like parent, children, or sibling, that allow you to start somewhere and follow a path to your element? Can you show us any HTML that would allow us to assist you?

1 Like

You should stop using the Recorder tool. The tool would be able to help you for easy problems, but could be short for difficult problems.

In order to solve your problems which the Recorder tool can not solve, you should study XPath technology by reading some tutorials like

and create Test Objects manually with XPath expressions (or CSS selectors) that clearly identify the Field1 and the Field2.

Thanks, It is working now. I created Test object manually.

1 Like

@himanisaxena19 , one of the best practices is always follow kazurayam’s advice. Technically, though, you cannot possibly have two objects with the same XPATH.

Let’s assume the “same xpath” you are talking about is “same_xpath”. If you do something like this (“same_xpath”)[1], (“same_xpath”)[2], you should be able to get to the 1st and the 2nd object respectively and these ("same_xpath")[1] and ("same_xpath")[2] would be 2 different xpathes for the 2 different objects