How to call the created Object Repository in Custom Keyword same pattern using TestObject?

doesn’t work my script calling created Object repo in custom keyword

can you share with us what you want to achieve?

hello @Andrej_Podhajsky I want to call created Object Repository under Custom Keyword

hello @Andrej_Podhajsky this code doesn’t work on my side.

public static TestObject makeTO(String xpath) {
TestObject to = new TestObject()
to.addProperty(“xpath”, ConditionType.EQUALS, xpath)
return to

TestObject SearchTextBox = makeTO(‘test1’)

1st … if you referring to existing record in RO use findTestObject(‘path/in/RO’) that will produce TO based on stored definition, than you can add xpath to it if you want…
what i’m wondering is why you need such construct when you can use variables in TO definition
also please share error that Katalon produces

I want to try to add the existing Object from object repository under Custom Keyword.

@Andrej_Podhajsky Is there a way to create a method for calling Object Repository in Custom keyword? if yes. Could you provide a sample code? thanks in advance :slight_smile:

You are probably needing some import statements, like below:

import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.testobject.ConditionType as ConditionType

and then you can make your TestObject in the Custom Keywords area:

TestObject myItem = com.Tools.makeTO('my xpath')

You can import all your needed statements by using the key combination of CTRL + Shift + O (oh).

And the code for the method, makeTO (or whatever you want to call it)

import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.testobject.ConditionType as ConditionType

static TestObject makeTO(String xpath) {
	TestObject to = new TestObject("${xpath}")
	to.addProperty("xpath", ConditionType.EQUALS, "${xpath}")
	return to

Hi @grylion54 @Andrej_Podhajsky is it possible to insert multiple value inside verifylemementvisible?
like this:

if(WebUI.verifyElementVisible(account||inplaymatrix||memberbalance||program||home||homesports||announcement) == true)


WebUI.verifyElementVisible keyword does not support “OR” operator of TestObjects.

Alternatively, XPath supports OR operator.

Have a look at

hi @kazurayam is there any way how to check all elements are visible is home page? or need one by one script like this:


If you want to check if ALL elements are visible in a page, yes, it is a good idea to check all of them one by one, just like you presented above. Why do you hesitate to do it?

@kazurayam Thanks for the info but I want to do like a short method hehe

Actucally the code won’t be as short as you imagine.

This psuedo code of “OR operations” example should rather be like this:

if (WebUI.verifyElementVisible(findTestobject("account"), FailureHandling.OPTIONAL)
    || WebUI.verifyElementVisible(findTestObject("inplaymatrix"), FailureHandling.OPTIONAL)
    || WebUI.verifyElementVisible(findTestObject("memberbalance"), FailureHandling.OPTIONAL)
    || WebUI.verifyElementVisible(findTestObject("program"), FailureHandling.OPTIONAL)
    || WebUI.verifyElementVisible(findTestObject("home"), FailureHandling.OPTIONAL)
    || WebUI.verifyElementVisible(findTestObject("homesports"), FailureHandling.OPTIONAL)
    || WebUI.verifyElementVisible(findTestObject("announcement"), FailureHandling.OPTIONAL) {
1 Like

@kazurayam alright! :slight_smile: thanks again for your assistance

@kazurayam error in my side. :frowning:

@kazurayam hello this code works fine.