Set variables to an object

For example, a button object is created to take a parameter for “buttonIndex”. There are 4 buttons on the page, so to pick the correct one, the value is passed in.
xpath //ul[text()=‘list_product’]//li[1] → //ul[text()=‘list_product’]//li[4]

I had set xpath : //ul[text()=‘list_product’]//li[${index}]
Then I create script: WebUI.click(findTestObject(‘Homepage/li_product’,[(‘index’) : 2]))

But the testcase failed. The error is ’ Unable to click on object ’ (Root cause: org.openqa.selenium.WebDriverException: chrome not reachable’
how should I deal with them

Hello,

this exception has nothing with your XPath. It says that Katalon cannot reach Chrome browser - is it opened?

Yes. It still run other step but this ‘WebUI.click(findTestObject(‘Homepage/li_product’,[(‘index’) : 2]))’.

Phan Ky Giang said:

For example, a button object is created to take a parameter for “buttonIndex”. There are 4 buttons on the page, so to pick the correct one, the value is passed in.
xpath //ul[text()=‘list_product’]//li[1] → //ul[text()=‘list_product’]//li[4]

I had set xpath : //ul[text()=‘list_product’]//li[${index}]
Then I create script: WebUI.click(findTestObject(‘Homepage/li_product’,[(‘index’) : 2]))

But the testcase failed. The error is ’ Unable to click on object ’ (Root cause: org.openqa.selenium.WebDriverException: chrome not reachable’
how should I deal with them

I have aready dealt with it. I didn’t know that the variable is global value.
So, you must create the global value first, then use it.