# Click on one of several buttons

**URL:** <https://forum.katalon.com/t/click-on-one-of-several-buttons/31451>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [August 13, 2019, 11:42am UTC](https://forum.katalon.com/t/click-on-one-of-several-buttons/31451 "2019-08-13T11:42:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbo\_atti76](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lbo\_atti76](https://forum.katalon.com/u/lbo_atti76)\
**Post date:** [August 13, 2019, 11:42am UTC](https://forum.katalon.com/t/click-on-one-of-several-buttons/31451/1 "2019-08-13T11:42:19Z")

</div>

I have to test buttons on a page. The number of buttons depends on the data.  
All buttons have the same name and open the same page with different data.

When I use the recorder, it creates the item "Click ".

But when I run the test, I have the error “Unable to click on object”

How to trigger the click on a particular button (the 2nd for example)?

Thank you very much for your help

---

<div class="post-metadata">

**Author:** ![hpulsford](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hpulsford/32/2985_2.png) [@hpulsford](https://forum.katalon.com/u/hpulsford)\
**Post date:** [August 13, 2019, 12:47pm UTC](https://forum.katalon.com/t/click-on-one-of-several-buttons/31451/2 "2019-08-13T12:47:11Z")

</div>

You could index the buttons on the page so it knows which one to select. So for example -

```auto
<input type="submit" id="button" value="Edit"/>
<input type="submit" id="button" value="Edit"/>
<input type="submit" id="button" value="Edit"/>

```

```auto
By.xpath("(//input[@type='submit'])[0]") ---> To Click 1st Button
By.xpath("(//input[@type='submit'])[1]") ---> To Click 2nd Button
By.xpath("(//input[@type='submit'])[2]") ---> To Click 3rd Button

```

---

<div class="post-metadata">

**Author:** ![sang](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sang/32/6357_2.png) [@sang](https://forum.katalon.com/u/sang)\
**Post date:** [August 13, 2019, 1:59pm UTC](https://forum.katalon.com/t/click-on-one-of-several-buttons/31451/3 "2019-08-13T13:59:33Z")

</div>

[lbo\_atti76](http://forum.katalon.com/u/lbo_atti76)

Can you share the screenshot and HTML source code, there are some techniques to get the XPATH that based on the data table.

`//td[contains(text(),'Francisco Chang')]//following-sibling::td//button`

 ![34%20PM](https://europe1.discourse-cdn.com/katalon/original/2X/9/93b987ff222c618ec9fe97d31efffcc8d968e1fa.png)

---

<div class="post-metadata">

**Author:** ![lbo\_atti76](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lbo\_atti76](https://forum.katalon.com/u/lbo_atti76)\
**Post date:** [August 13, 2019, 2:28pm UTC](https://forum.katalon.com/t/click-on-one-of-several-buttons/31451/4 "2019-08-13T14:28:39Z")

</div>

The screenshoot :

 ![Capture](https://europe1.discourse-cdn.com/katalon/original/2X/2/27aad5b854226c3e8fadeca6ae381711973526dd.png)

I would like to click on the 2nd button “Sélectionner ce dossier” (line “QA TELESERVICE FILS 10/10/2000”)

Here is the code of the html page  
[code.html](https://europe1.discourse-cdn.com/katalon/original/2X/8/80731263bdbead7095421dd6773fef78ebdc2d8c.html) (8.5 KB)

---

<div class="post-metadata">

**Author:** ![sang](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sang/32/6357_2.png) [@sang](https://forum.katalon.com/u/sang)\
**Post date:** [August 13, 2019, 3:03pm UTC](https://forum.katalon.com/t/click-on-one-of-several-buttons/31451/5 "2019-08-13T15:03:09Z")

</div>

[lbo\_atti76](http://forum.katalon.com/u/lbo_atti76) you can try with “_preceding_” to get the element on the right side. Example:

 ![44%20PM](https://europe1.discourse-cdn.com/katalon/original/2X/4/49dcf8c3cba01d2510fb1d514e79218c3bd216c4.png)

In your case:

 ![50%20PM](https://europe1.discourse-cdn.com/katalon/original/2X/3/3626cf0c27839f2f51747bc4bffbe7e96939b572.png)

`//td[contains(text(),'FILS')]//preceding::td[3]`

---

<div class="post-metadata">

**Author:** ![lbo\_atti76](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lbo\_atti76](https://forum.katalon.com/u/lbo_atti76)\
**Post date:** [August 14, 2019, 10:19am UTC](https://forum.katalon.com/t/click-on-one-of-several-buttons/31451/6 "2019-08-14T10:19:10Z")

</div>

Thank you sang  
To test your answer, I recreated the test this morning, using the same data and doing the same actions.  
And today, it works. I do not understand.  
All the better. But I’m sorry for making you waste time.  
Thank you so much.
