# Clicking on two identical buttons in the same screen

**URL:** <https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [January 27, 2020, 1:42pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098 "2020-01-27T13:42:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 27, 2020, 1:42pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/1 "2020-01-27T13:42:50Z")

</div>

Hello all,  
I’m trying to auto-test a page that has various buttons with letters on them, and only certain buttons need to be clicked to spell a word.  
All buttons have the same class, the only thing different is the text.  
I defined each button by the text clicked (the letter) and the class, and used “click”:

WebUI.click(findTestObject(‘Object Repository/Page\_/button\_r’))  
WebUI.click(findTestObject(‘Object Repository/Page\_/button\_e’))  
WebUI.click(findTestObject(‘Object Repository/Page\_/button\_d’))  
etc…

Everything worked fine until I got to a word with two identical letters (for example, “green”). Then It’s only clicking the first “e”, and not the other (it’s trying to click again on the first “e”) - even if I create two separate test objects and even if I separate their folders:  
WebUI.click(findTestObject(‘Object Repository/Page\_/button\_e’))  
WebUI.click(findTestObject(‘Object Repository/button\_e\_second’))

I tried to verify that the element is clickable before clicking it (because each button is disabled after use):  
WebUI.verifyElementClickable(findTestObject(‘Object Repository/Page\_/button\_e’))  
WebUI.click(findTestObject(‘Object Repository/Page\_/button\_e’))  
WebUI.verifyElementClickable(findTestObject(‘Object Repository/button\_e\_second’))  
WebUI.click(findTestObject(‘Object Repository/button\_e\_second’))  
But then I get an error in the “verify element clickable” stage stating that the element is NOT clickable (cause it’s still referring to the previous one).  
Here’s the log:  
Reason:  
com.kms.katalon.core.exception.StepFailedException: Unable to verify object ‘Object Repository/button\_e\_second’ to be clickable  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)  
at com.kms.katalon.core.webui.keyword.builtin.VerifyElementClickableKeyword.verifyElementClickable(VerifyElementClickableKeyword.groovy:96)  
at com.kms.katalon.core.webui.keyword.builtin.VerifyElementClickableKeyword.execute(VerifyElementClickableKeyword.groovy:67)  
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementClickable(WebUiBuiltInKeywords.groovy:562)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementClickable$2.call(Unknown Source)  
at Imagegame temp.run(Imagegame temp:53)  
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)  
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)  
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)  
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)  
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)  
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)  
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)  
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)  
at TempTestCase1580125918488.run(TempTestCase1580125918488.groovy:23)  
Caused by: com.kms.katalon.core.exception.StepFailedException: Object ‘Object Repository/button\_e\_second’ is NOT clickable

Does anybody knows how to make Katalon click two buttons one after the other, even if they are defined the same?  
Thanks!

---

<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:** [January 27, 2020, 2:03pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/2 "2020-01-27T14:03:39Z")

</div>

> [@](#):
>
> Everything worked fine until I got to a word with two identical letters (for example, “green”). Then It’s only clicking the first “e”, and not the other (it’s trying to click again on the first “e”)

Actually, it didn’t work fine. Your algorithm didn’t cover the problem domain.

> [@](#):
>
> even if I create two separate test objects and even if I separate their folders

That’s because your choice of algorithm is fixed, it can’t “dynamically adapt” to the change in your head, and the code (and browser) really don’t care where you store these things in Katalon.

> [@i-melingo](#):
>
> I tried to verify that the element is clickable before clicking it (because each button is disabled after use)  
> …  
> But then I get an error in the “verify element clickable” stage stating that the element is NOT clickable (cause it’s still referring to the previous one).

That’s right, because it’s the same algorithm which you’ve already proved is faulty.

> [@i-melingo](#):
>
> Does anybody knows how to make Katalon click two buttons one after the other, even if they are defined the same?

Yes, we do. You made a good job of showing us the _results_ of your trials but you didn’t show us the definitions of your Test Objects. Do they use CSS? XPath? How do the buttons fit into the structure of the HTML document in the page?

If you read this post, you’ll get some good advice about how to report errors:

> [@\[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:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 28, 2020, 4:24pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/3 "2020-01-28T16:24:03Z")

</div>

Hi,  
Thank you for your answer.  
That’s my test object (it’s defined by text & class):

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/6/6df4253a1941007e8715fddbf652ca7984228709.png)  
I also tried defining it by xpath with a regex (because the letters can appear under two possible parent IDs):  
 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/7/7d0733b839dc70eb08410f2904ed27b21e1b5e4c.png)

That’s the HTML relevant part (see the letter e that appears twice):

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/1/16b0bbdd0b5619eb8727de44126470e69b94d9af.png)

Thanks in advance!

---

<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:** [January 28, 2020, 4:29pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/4 "2020-01-28T16:29:48Z")

</div>

If you were using CSS, I’d advise you to use an index, `nth-child(n)` to reach the correct/target button. But I don’t use XPath so I can’t help.

However, I think @Brandon_Hein knows a little bit about XPath… 😉

Sit tight. Let him have his third cup of coffee, and wait for him to help. 🙂

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [January 28, 2020, 6:54pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/5 "2020-01-28T18:54:38Z")

</div>

Is the word that you need to spell consistent between runs of your test (I would hope so, otherwise I’m not sure how you would test it)? If you know which word you need to spell every time, then I would ditch trying to use the text of the button, and just pass in an index. The xpath in your test object would look something like this:

`//div[@id='spellingLetters0']/button[${index}]`

Then your test code would click each button you’d like by passing an index like so:

```
WebUI.click(findTestObject(‘Object Repository/Page_/button’, ['index' : 1]))
WebUI.click(findTestObject(‘Object Repository/Page_/button’, ['index' : 2]))
.
.
.
WebUI.click(findTestObject(‘Object Repository/Page_/button’, ['index' : n]))
```

---

<div class="post-metadata">

**Author:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 29, 2020, 7:43am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/6 "2020-01-29T07:43:20Z")

</div>

Hi,  
Thanks @Brandon_Hein and @Russ_Thomas!  
The word I’m spelling is always the same (for example “green”), but unfortunately, the order of the letters changes every time I open the game (there are 12 different letters that I should choose 5 of them to spell “green”, but the order changes and the redundant letters change), so I can’t use their location (if I understand what you mean by index).  
Any other advice? Maybe using the fact that a letter that was used is disabled?

Thanks again for your time!

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [January 29, 2020, 8:01am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/7 "2020-01-29T08:01:00Z")

</div>

> [@i-melingo](#):
>
> letters changes every time I open the game (there are 12 different letters that I should choose 5 of them to spell “green”, but the order changes and the redundant letters change), so I can’t use their location (if I understand what you mean by index).

does the “game” distinguish between those letters? if not, you don’t need either … that means you can allways press letter\_e\_button[1] first and letter\_e\_button[2] second… game should not care (if yes, it’s bug)

---

<div class="post-metadata">

**Author:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 29, 2020, 8:10am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/8 "2020-01-29T08:10:01Z")

</div>

@Andrej_Podhajsky There’s no difference between the two e buttons, as far as I can tell.  
I tried to create two test objects, button\_e and button\_e\_second, but Katalon says it clicked both, but actually only clicks one (In the log I see “click button\_e”, “click button\_e\_second”, “click button\_n”, but on the screen it only spells “gren” and then get stuck because the word wasn’t really completed).  
Can you please show me how you would define the test objects?

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [January 29, 2020, 8:52am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/9 "2020-01-29T08:52:16Z")

</div>

Object button:  
xpath=(//button[contains(@class,‘spelling\_letter’) and contains(text(),’$LETTER’)])[$INDEX]

call will be:  
WebUI.click(findTestObject(‘Object Repository/Page\_/button’,[(‘LETTER’):‘e’, (‘INDEX’):1]))  
WebUI.click(findTestObject(‘Object Repository/Page\_/button’,[(‘LETTER’):‘e’, (‘INDEX’):2]))

also you need to adjust xpath to fit your need

---

<div class="post-metadata">

**Author:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 29, 2020, 9:27am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/10 "2020-01-29T09:27:38Z")

</div>

Thanks @Andrej_Podhajsky , I tried to use your structure but Katalon can’t click the button when I get to this part, I get this error:  
Reason:  
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page\_/button\_e’  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:103)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)  
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$1.call(Unknown Source)  
at Imagegame temp.run(Imagegame temp:51)  
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)  
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)  
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)  
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)  
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)  
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)  
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)  
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)  
at TempTestCase1580289842403.run(TempTestCase1580289842403.groovy:23)  
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page\_/button\_e’ located by ‘By.xpath: (//button[contains(@class,‘spelling\_letter’) and contains(text(),’$LETTER’)])[$INDEX]’ not found

This is how I defined the test object:

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/d/db89bed9e535296fb4b6f45950044c08e57b93cf.png)

I’m not quite sure what the “index” part means - is it the location of the letter? Because if so, it’s a problem to use index1 and index2, because these e’s can be anywhere between the 12 buttons.

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [January 29, 2020, 9:30am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/11 "2020-01-29T09:30:10Z")

</div>

use attributes as selection method … variables are not working in XPath Selection method

> I’m not quite sure what the “index” part means - is it the location of the letter? Because if so, it’s a problem to use index1 and index2, because these e’s can be anywhere between the 12 buttons.

index is occurance:  
xpath like :  
//button[contains(@class,‘spelling\_letter’) and contains(text(),’e’)]  
will return 2 objects - this is not allowed in OR  
therefore you need to pinpoint which of those 2 object you want to use … it’s not about position on screen (simplification) but about position on DOM.  
so (//button[contains(@class,‘spelling\_letter’) and contains(text(),’e’)])[1] will adress 1st button with letter ‘e’ (//button[contains(@class,‘spelling\_letter’) and contains(text(),’e’)])[2] will address 2nd object

to better understand how xpath works i suggest to install any plugin to browser that will allow you to test your xpath and will show results of xpath query

---

<div class="post-metadata">

**Author:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 29, 2020, 10:22am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/12 "2020-01-29T10:22:26Z")

</div>

@Andrej_Podhajsky thank you so much!  
I created two test objects for e:  
//button[contains(@class,‘spelling\_letter’) and contains(text(),’e’)])[1]  
//button[contains(@class,‘spelling\_letter’) and contains(text(),’e’)])[2]  
And it worked perfectly!

It didn’t work when I tried the first suggestion, to define the object like this: xpath=(//button[contains(@class,‘spelling\_letter’) and contains(text(),’$LETTER’)])[$INDEX] and then in the test case do the call like this: WebUI.click(findTestObject(‘Object Repository/Page\_/button’,[(‘LETTER’):‘e’, (‘INDEX’):1])), maybe I have some mistake somewhere, but since I don’t have a lot of these doubles, I can just duplicate the necessary buttons.

Thanks again for your patience and help! 🙂

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [January 29, 2020, 10:28am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/13 "2020-01-29T10:28:18Z")

</div>

to get work parameters use Attributes as Selection method on Object definition:

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/3/37a2632169da37a2f4d1029d5514ef100cbef831.png)

---

<div class="post-metadata">

**Author:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 29, 2020, 10:33am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/14 "2020-01-29T10:33:56Z")

</div>

Yeah I did this, but it didn’t work. Maybe there was something wrong with the test case itself?

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [January 29, 2020, 11:28am UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/15 "2020-01-29T11:28:47Z")

</div>

can you share code/call you used when it fails?

---

<div class="post-metadata">

**Author:** ![danpoleary](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/danpoleary/32/2416_2.png) [@danpoleary](https://forum.katalon.com/u/danpoleary)\
**Post date:** [January 29, 2020, 1:03pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/16 "2020-01-29T13:03:42Z")

</div>

I would get the code changed in the game and assign unique ID’s to each button like “e1” and “e2”. This would be easy on the game code side and greatly simplify what you are trying to do.

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [January 29, 2020, 2:07pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/17 "2020-01-29T14:07:39Z")

</div>

Ok, so dev should implement every word separately?  
try to force them to impement Popocatepetl…

---

<div class="post-metadata">

**Author:** ![i-melingo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/i-melingo/32/16104_2.png) [@i-melingo](https://forum.katalon.com/u/i-melingo)\
**Post date:** [January 29, 2020, 2:30pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/18 "2020-01-29T14:30:47Z")

</div>

I tried this definition for the test object (using Attribute as selection method):  
(//button[contains(@class,‘spelling\_letter’) and contains(text(),’$LETTER’)])[$INDEX]

And then the call was:  
WebUI.click(findTestObject(‘Object Repository/Page\_/button’,[(‘LETTER’):‘e’, (‘INDEX’):1]))  
WebUI.click(findTestObject(‘Object Repository/Page\_/button’,[(‘LETTER’):‘e’, (‘INDEX’):2]))

And I got an error that object was not found.

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [January 29, 2020, 3:11pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/19 "2020-01-29T15:11:00Z")

</div>

OK so the order of the buttons changes, and it sounds like you cannot click the same button twice. In this case, you would need to identify the buttons using text AND position (index):

`//div[@id='spellingLetters0']/button[text()='${text}'][${index}]`

```
WebUI.click(findTestObject(‘Object Repository/Page_/button’, ['text' : 'e', 'index' : 1]))
WebUI.click(findTestObject(‘Object Repository/Page_/button’, ['text' : 'e', 'index' : 2]))

```

Although, as others have suggested, if you have any say in the implementation of the HTML/JS, I would try get an ID in there that would make your life easier.

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [January 29, 2020, 3:26pm UTC](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098/20 "2020-01-29T15:26:01Z")

</div>

My fault … sorry …

> [@Andrej\_Podhajsky](#):
>
> Object button:  
> xpath=(//button[contains(@class,‘spelling\_letter’) and contains(text(),’$LETTER’)])[$INDEX]

should be

```auto
xpath=(//button[contains(@class,‘spelling_letter’) and contains(text(),"${LETTER}")])[${INDEX}]

```

i missed curly brackets …

[Next page](https://forum.katalon.com/t/clicking-on-two-identical-buttons-in-the-same-screen/39098.md?page=2)
