Unable to retrieve xpath value from object repository object, why?

So I’ve tried several methods for retrieving the xpath from an object repository item and none are successful, trying to understand why.

so the Object in the repository is using the Xpath selection method, with a locator format of //table[@id=‘table-identifier’], which doing a search here on the forums indicates should be retrievable via the following code:

this_object = findTestObject('Object Repository/full_path')
my_xpath = this_object.findPropertyValue("xpath")
log.logInfo ('xpath property: ' + my_xpath)

yet my_xpath is always empty. I’ve also tried with .getAttributes [results in null], and .findProperty [also null], what might I be doing wrong?

The following post of my might be interesting for you:

The following code retrieves the internal of a TestObject (you do not need to add any external jar).
Please change the id of TestObject to retrieve to your target.

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

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

import groovy.json.JsonOutput

TestObject tObj = findTestObject('Object Repository/Page_CURA Healthcare Service/a_Make Appointment_BASIC')

String json = JsonOutput.toJson(tObj)
println json

println JsonOutput.prettyPrint(json)


from TestObjectExtension/Script1627951034417.groovy at master · kazurayam/TestObjectExtension · GitHub

1 Like

This worked! Thanks!