# Can You Help with Variable in web test object?

**URL:** <https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575>\
**Category:** Miscellaneous\
**Tags:** variables, locators\
**Created:** [October 31, 2024, 12:34pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575 "2024-10-31T12:34:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![aki](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/aki/32/23869_2.png) [@aki](https://forum.katalon.com/u/aki)\
**Post date:** [October 31, 2024, 12:34pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/1 "2024-10-31T12:34:02Z")

</div>

Hi everyone,

I’m new to automated testing and to Katalon Studio, so I apologize if this is a basic question:  
I’m experiencing an issue with variables in XPath in Katalon Studio.  
In my test case, I assigned the variable as a string with the value **“KatalonTest2”**. However, Katalon cannot locate the object when I use this variable format.  
On the other hand, if I replace `${test123}` directly with the static text **“KatalonTest2”** in the XPath expression then it finds the object successfully.

I’m attaching screenshots showing both situations: one with the variable that fails, and one with the static text that works.

 ![success](https://europe1.discourse-cdn.com/katalon/original/3X/b/3/b37fe1fb9dbf21ee362b4e0dab145de9ad2b4d45.png)

 ![failed](https://europe1.discourse-cdn.com/katalon/original/3X/1/3/13ec5fbb5f87e4bfd87c62b47ffbf526f0619297.png)

Could anyone explain why this might be happening or offer any tips on using variables.  
Thanks so much in advance!

---

<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:** [October 31, 2024, 12:43pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/2 "2024-10-31T12:43:07Z")

</div>

The characters in the screenshots are too small, hardly readable. Please provide readable ones.

---

<div class="post-metadata">

**Author:** ![aki](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/aki/32/23869_2.png) [@aki](https://forum.katalon.com/u/aki)\
**Post date:** [October 31, 2024, 12:59pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/3 "2024-10-31T12:59:42Z")

</div>

Hello,  
I’m currently using a Xiaomi 11T Pro, which has a 6.67-inch display, and with a certain level of zoom, I can read and see all the characters clearly.

---

<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:** [October 31, 2024, 1:10pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/4 "2024-10-31T13:10:00Z")

</div>

OK

I don’t know how to see it. So I would quit.

---

<div class="post-metadata">

**Author:** ![Monty\_Bagati](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/monty_bagati/32/33047_2.png) [@Monty\_Bagati](https://forum.katalon.com/u/Monty_Bagati)\
**Post date:** [October 31, 2024, 1:24pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/5 "2024-10-31T13:24:02Z")

</div>

could you please try to use the “li” tag as i see its a list. this may be creating a problem. also check whether there are any escaping characters.

---

<div class="post-metadata">

**Author:** ![aki](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/aki/32/23869_2.png) [@aki](https://forum.katalon.com/u/aki)\
**Post date:** [October 31, 2024, 2:05pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/6 "2024-10-31T14:05:01Z")

</div>

I also tried using the “li” tag and have no escaping characters. Interestingly, this works in Katalon Recorder (the Chrome extension), but it doesn’t work in Katalon Studio.

 ![2024-10-31 14_49_59-](https://europe1.discourse-cdn.com/katalon/original/3X/6/e/6e32f64a2884294b9eea8e834e69b95cf149dece.png)

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [October 31, 2024, 2:05pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/7 "2024-10-31T14:05:01Z")

</div>

Hi there, and thanks for posting in the Katalon community! 🤗

To help you faster, please review our guide on Katalon Recorder here: [Katalon Recorder overview | Katalon Docs](https://docs.katalon.com/katalon-platform/plugins-and-add-ons/katalon-recorder-extension/get-started/katalon-recorder-overview). Double-checking the steps and configurations might resolve the issue.

If the doc doesn’t help, feel free to provide more details, and a community member will assist you soon. Thanks for being a part of our community!

Best,  
Albert Le

---

<div class="post-metadata">

**Author:** ![Monty\_Bagati](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/monty_bagati/32/33047_2.png) [@Monty\_Bagati](https://forum.katalon.com/u/Monty_Bagati)\
**Post date:** [October 31, 2024, 2:06pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/8 "2024-10-31T14:06:12Z")

</div>

can u use the li tag in your manually created xpath and check. I feel it would work

---

<div class="post-metadata">

**Author:** ![aki](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/aki/32/23869_2.png) [@aki](https://forum.katalon.com/u/aki)\
**Post date:** [October 31, 2024, 3:51pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/9 "2024-10-31T15:51:39Z")

</div>

I already mentioned that I tried it, but it doesn’t work…

---

<div class="post-metadata">

**Author:** ![Dan\_Bown](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dan_bown/32/20464_2.png) [@Dan\_Bown](https://forum.katalon.com/u/Dan_Bown)\
**Post date:** [October 31, 2024, 6:17pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/10 "2024-10-31T18:17:25Z")

</div>

Make sure you have only 1 element found before you create your dynamic object. Your first screenshot shows that you found 2. This means your script will fail.

---

<div class="post-metadata">

**Author:** ![viet.nguyen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/viet.nguyen/32/21142_2.png) [@viet.nguyen](https://forum.katalon.com/u/viet.nguyen)\
**Post date:** [November 1, 2024, 4:23am UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/11 "2024-11-01T04:23:56Z")

</div>

Hi, some resources you can check out:

1. How to work with locators in Katalon Studio: [https://academy.katalon.com/courses/creating-reliable-web-test-object-locators/](https://academy.katalon.com/courses/creating-reliable-web-test-object-locators/)
2. How to parameterize value for test objects: [https://academy.katalon.com/courses/parameterize-test-objects/](https://academy.katalon.com/courses/parameterize-test-objects/)

---

<div class="post-metadata">

**Author:** ![cmor](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/cmor/32/23870_2.png) [@cmor](https://forum.katalon.com/u/cmor)\
**Post date:** [November 7, 2024, 5:13pm UTC](https://forum.katalon.com/t/can-you-help-with-variable-in-web-test-object/153575/12 "2024-11-07T17:13:43Z")

</div>

You also need to add the script variable to the script action that needs to use it.  
Looking at your first screenshot the action that needs it is on row 10. Doubleclick on the li\_KatalonTest2 object and add the script variable in the popup screen.  
Like so:

 ![afbeelding](https://europe1.discourse-cdn.com/katalon/original/3X/6/b/6b3389d1619c07a2f03f5a1a58eff684b3b5e8e8.png)
