findTestObject('//*[@name="marketId"]') returns null

test code>>>
WebUI.openBrowser(‘file:///users/cames/eclipse-workspace/depot/pkgs/sde/tools/QcTool-QaAutomation/SelectTest.html’)

WebUI.waitForPageLoad(5)

ItemCount = WebUI.getNumberOfTotalOption(findTestObject(’//*[@name=“marketId”]’))
<<<

web page>>>

Insert title here --All-- 2G_POST_FILE_SIZE_TEST 3G_POST_FILE_SIZE_TEST 46 EVDOREVALEGACY <<<

error>>>
Test Cases/SelectTest FAILED.

Reason:

com.kms.katalon.core.exception.StepFailedException: Unable to get total options of object (Root cause: java.lang.IllegalArgumentException: Object is null)

at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)

<<<

findTestObject method expects a path to Test Object in Object Repository, not actual xpath. If you want to use xpath directly in your test case, use this code:

import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

TestObject to = new TestObject().addProperty('xpath', ConditionType.EQUALS, "//*[@name='marketId']")
ItemCount = WebUI.getNumberOfTotalOption(to)
1 Like

Thank you Marek for the quick reply - solution worked great

On a separate note, how do we suggest updates to the Katalon examples / documentation to surface this earlier?

I think Test Object is documented well. See this article:

https://docs.katalon.com/katalon-studio/docs/manage-test-object.html#test-objects-in-scripting-view