How to paramterize xpath object properties and use it inside test case?

Hello, I am new to Katalon, currently evaluating it; going from RobotFW with Selenium2Library…

Say I need many objects with properties selection method is XPath and my Selector Editor is like below:
.//td[contains(text(),‘abc1’)]

.//td[contains(text(),‘xyz100’)]

How can I parameterize the the object properties, so that I can just have 1 object and pass in the search string on the fly, inside the test case? Thanks

Below is what I have tried by not working

my xpath object, myobj1, Selector Editor content:
.//td[contains( text(), [${myStr}] )]

then inside testcase:
WebUI.click(findTestObject(‘mypage/myobj1’, [(‘myStr’) : ‘abc1’]))

Hi ai test,

You can only use this feature from ‘Basic’ mode. This feature does not available on CSS and Xpath mode, so your case will look like this:

2018-01-03_083536.png

Hello Vinh,
Thank you for the information.
Now, I have changed my object Selection Method to Basic type and Add the xpath property exactly as you have shown in your image and saved the object, but test is not able to locate object.

Test error, still same as before, when I had Selection Method type XPath:
Test Cases/tcase1 FAILED because (of) Unable to click on object ‘Object Repository/mypage/myobj1’ Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/mypage/myobj1’ located by ‘By.xpath: .//td[contains( text(),[abc1])]’ not found)

Hi ai test,

That is not the correct xpath. In this case it should be:
.//td[contains( text(),"${myStr}" )]

Awesome, thanks Vinh! that works

am new to this, can you explain ${myStr}, can you give an example code
how to declare this in manual mode

Jaikumar,

can you explain ${myStr},

Have a look at the Groovy Language’s String interpolation documentation:

http://docs.groovy-lang.org/latest/html/documentation/#_string_interpolation