# Unable to find an element using parameter in attributes (worked in the past)

**URL:** <https://forum.katalon.com/t/unable-to-find-an-element-using-parameter-in-attributes-worked-in-the-past/103995>\
**Category:** Web Testing\
**Tags:** web-testing\
**Created:** [November 8, 2023, 3:23pm UTC](https://forum.katalon.com/t/unable-to-find-an-element-using-parameter-in-attributes-worked-in-the-past/103995 "2023-11-08T15:23:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaakovd\_katalon](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/yaakovd_katalon/32/23869_2.png) [@yaakovd\_katalon](https://forum.katalon.com/u/yaakovd_katalon)\
**Post date:** [November 8, 2023, 3:23pm UTC](https://forum.katalon.com/t/unable-to-find-an-element-using-parameter-in-attributes-worked-in-the-past/103995/1 "2023-11-08T15:23:58Z")

</div>

Running Katalon Studio 8.6.8.  
Using syntax that worked in the past, I cannot locate an element using a parameter in the object’s attributes.  
Here is the object:  
 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/7/d/7df4fb88fef18e9d32e01b83fd626bbb49686291.png)

I am **able** to find the element with these attributes:  
 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/6/2/628e283c5f318af76fdc8cbeac73561887f60e7f.png)

I am **unable** to find the element with a parameter defined as follows:  
 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/0/3/03a9fa0882e13a2ac3bb63df3528ae6e41bac69d.png)

My code assigns a value to ‘id’ immediately before the ‘click’:  
id = ‘minor-child2-dob’.

Here is the error message:  
2023-11-08 17:19:13.992 DEBUG testcase.Experiments template - 10: id = “minor-child2-dob”  
2023-11-08 17:19:13.995 DEBUG testcase.Experiments template - 11: click(findTestObject(“01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test”))  
2023-11-08 17:19:45.276 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //_[@name = ‘${id}’ and @id = ‘${id}’]'. Please recheck the objects properties to make sure the desired element is located.  
2023-11-08 17:19:45.499 ERROR c.k.k.core.keyword.internal.KeywordMain - ❌ Unable to click on object ‘Object Repository/01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test’  
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:74)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:40)  
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:620)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$4.call(Unknown Source)  
at Experiments template.run(Experiments template:102)  
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:448)  
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)  
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)  
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)  
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)  
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)  
at TempTestCase1699456722213.run(TempTestCase1699456722213.groovy:25)  
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test’ located by '//_[@name = ‘${id}’ and @id = ‘${id}’]’ not found  
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1381)  
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$\_click\_closure1.doCall(ClickKeyword.groovy:65)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$\_click\_closure1.call(ClickKeyword.groovy)  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:74)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:40)  
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:620)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$4.call(Unknown Source)  
at Script1699164943408.run(Script1699164943408.groovy:102)  
… 11 more  
)  
2023-11-08 17:19:45.502 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/Experiments template FAILED.  
Reason:  
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test’  
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:74)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:40)  
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:620)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$4.call(Unknown Source)  
at Experiments template.run(Experiments template:102)  
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:448)  
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)  
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)  
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)  
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)  
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)  
at TempTestCase1699456722213.run(TempTestCase1699456722213.groovy:25)  
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test’ located by ‘//\*[@name = ‘${id}’ and @id = ‘${id}’]’ not found  
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1381)  
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$\_click\_closure1.doCall(ClickKeyword.groovy:65)  
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$\_click\_closure1.call(ClickKeyword.groovy)  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)

I’ve searched the message boards and have tried many of the suggested solutions, but they have not worked. Thanks in advance.

---

<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:** [November 8, 2023, 4:44pm UTC](https://forum.katalon.com/t/unable-to-find-an-element-using-parameter-in-attributes-worked-in-the-past/103995/2 "2023-11-08T16:44:47Z")

</div>

> [@yaakovd\_katalon](#):
>
> click(findTestObject(“01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test”))

Did you form your parameterize statement like below? Note the second pair of square brackets within the paramerization as per [KS](https://docs.katalon.com/docs/create-tests/test-objects/web-test-objects/parameterize-web-test-objects-in-katalon-studio).

```auto
WebUI.waitForElementVisible(findTestObject("01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test", ['id': "minor-child2-dob", [('name'): "minor-child2-dob"]]), 10)
WebUI.click(findTestObject("01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test", ['id': "minor-child2-dob", [('name'): "minor-child2-dob"]]))

```

Edit: if your **id** is unique, you do **not** need the **name** as well.

Edit2: I have done one parameterized variable within my code, but I have not done two, so I **don’t know** if one variable has to be first or not, like “name” then “id” or “id” then “name” or if it doesn’t matter.

---

<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:** [November 8, 2023, 5:10pm UTC](https://forum.katalon.com/t/unable-to-find-an-element-using-parameter-in-attributes-worked-in-the-past/103995/3 "2023-11-08T17:10:46Z")

</div>

Here is another idea that creates a Test Object in code at run time. Instead of the bulky parameterization statement, this to me is much “simpler” to look at.

> [@Creation of Test Object in Object Repository in Runtime](http://forum.katalon.com/t/creation-of-test-object-in-object-repository-in-runtime/10333/17):
>
> A sample Test Case that creates a TestObject runtime import com.kms.katalon.core.model.FailureHandling import com.kms.katalon.core.testobject.ConditionType import com.kms.katalon.core.testobject.TestObject import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI def createTestObjectByXPath(id, xpath) { TestObject tObj = new TestObject(id) tObj.addProperty('xpath', ConditionType.EQUALS, xpath) return tObj } WebUI.openBrowser('') WebUI.navigateToUrl("http://demoaut.katalon.co…

Create a **Keyword** like @kazurayam or @Russ_Thomas have of the “makeTO” method and then pass the pathway (either CSS or XPath) to create a Test Object, like:

```auto
myAssistant = com.Tools.makeTO("//*[@name='minor-child2-dob' and @id='minor-child2-dob']")
WebUI.click(myAssistant)

```

Edit: Do NOT create two methods **exactly** alike to do CSS **and** XPath because you will get an error. You must have two different names; one to do CSS and another to do XPath, like “makeTO” which could do XPath and “createTO” which could do CSS (because the method starts with “C” ). 🙂

---

<div class="post-metadata">

**Author:** ![yaakovd\_katalon](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/yaakovd_katalon/32/23869_2.png) [@yaakovd\_katalon](https://forum.katalon.com/u/yaakovd_katalon)\
**Post date:** [November 9, 2023, 6:48am UTC](https://forum.katalon.com/t/unable-to-find-an-element-using-parameter-in-attributes-worked-in-the-past/103995/4 "2023-11-09T06:48:53Z")

</div>

@grylion54  
Hi Mike. Thanks very much for your responses.  
First - of course you are right that I needed to use only one unique ID, not both.  
I was able to get it working per your first solution, passing in the value in the code.

**However** , what once worked in Katalon, where the object in the Repository has a value like ${id}, and “id” is a variable set in the code - does not seem to work any longer. I am continuing to check/try.

That solution allowed setting the ID to **any** dynamic value and not having to know the set of valid values in advance and passing them in explicitly. Sometimes the objects on the page have dynamic values - like username - and I can Get Text from Object A containing the username, set the “id” to that Text, and click on another object that has that “id” variable as an attribute value, where the “id” is evaluated in real time.

Some time ago, I had it working as described in  
[https://docs.katalon.com/docs/create-tests/test-objects/web-test-objects/parameterize-web-test-objects-in-katalon-studio](https://docs.katalon.com/docs/create-tests/test-objects/web-test-objects/parameterize-web-test-objects-in-katalon-studio)

This screenshot is from the above doc. I have not gotten it to work using ${id} as in their example.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/4/8/489603ea5407b02f007efb3c8015b9192bdd02ff.png)

Thanks again.

---

<div class="post-metadata">

**Author:** ![yaakovd\_katalon](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/yaakovd_katalon/32/23869_2.png) [@yaakovd\_katalon](https://forum.katalon.com/u/yaakovd_katalon)\
**Post date:** [November 9, 2023, 7:42am UTC](https://forum.katalon.com/t/unable-to-find-an-element-using-parameter-in-attributes-worked-in-the-past/103995/5 "2023-11-09T07:42:05Z")

</div>

@grylion54

I should have tried it before my last note - I see that your method allows for a variable to be passed in, as follows:  
WebUI.click(findTestObject(“01 Customer Screens/004 1583 Assistant/1 - Step 0 and 1 Objects/Step 1 99 Parameter Test”, [‘id’: id]))

So if I grab “id” from a dynamic part of the screen, I can use it as an attribute value for a different object without explicitly listing in the call.

All the best.
