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.
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.
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.
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. 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!
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.
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: