# Two objects with the same XPATH and attributes

**URL:** <https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [September 7, 2022, 9:51am UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358 "2022-09-07T09:51:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![himanisaxena19](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/himanisaxena19/32/16104_2.png) [@himanisaxena19](https://forum.katalon.com/u/himanisaxena19)\
**Post date:** [September 7, 2022, 9:51am UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358/1 "2022-09-07T09:51:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 7, 2022, 1:35pm UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358/2 "2022-09-07T13:35:04Z")

</div>

More details, please…

> [@\[TIP\] How To Help Us Help You!](http://forum.katalon.com/t/tip-how-to-help-us-help-you-my-test-is-broken-nothing-works-updated-nov-2019/12919):
>
> My test is BROKEN! NOTHING WORKS! HELP ME! Relax. We get it. We really do. There are some pretty smart and clever people on this forum, but you must realize, they are not magicians or wizards or gods. They cannot see your code, they can’t see your errors and they don’t even know what your AUT is meant to do even though it might seem perfectly obvious to you. So please relax and follow the advice below, before you start writing your post. The advice below will tell you the exact information …

---

<div class="post-metadata">

**Author:** ![himanisaxena19](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/himanisaxena19/32/16104_2.png) [@himanisaxena19](https://forum.katalon.com/u/himanisaxena19)\
**Post date:** [September 7, 2022, 2:43pm UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358/3 "2022-09-07T14:43:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [September 8, 2022, 12:09am UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358/4 "2022-09-08T00:09:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 8, 2022, 1:25am UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358/5 "2022-09-08T01:25:26Z")

</div>

> [@himanisaxena19](#):
>
> I did recording and when trying to execute the script, it is identifying only 1st object.

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

- [XPath in Selenium: How to Find & Write? (Text, Contains, AND)](https://www.guru99.com/xpath-selenium.html)

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

---

<div class="post-metadata">

**Author:** ![himanisaxena19](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/himanisaxena19/32/16104_2.png) [@himanisaxena19](https://forum.katalon.com/u/himanisaxena19)\
**Post date:** [September 8, 2022, 10:57am UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358/6 "2022-09-08T10:57:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gdearest07](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/gdearest07/32/22419_2.png) [@gdearest07](https://forum.katalon.com/u/gdearest07)\
**Post date:** [September 8, 2022, 11:33am UTC](https://forum.katalon.com/t/two-objects-with-the-same-xpath-and-attributes/69358/7 "2022-09-08T11:33:41Z")

</div>

@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
