How to log the object id (property) in script

Hi there,

I want to log my object ID to check my adjustment is working or not.(I want to adjust the id value)
But it looks not success.

TestObject tobj = new TestObject("testObject")
tobj.addProperty("id", ConditionType.EQUALS, "qa-4",true)
println(tobj.getObjectId())
println(MessageFormat.format(StringConstants.CONF_PROPERTY_EXECUTION_SOURCE_ID,tobj.getObjectId()))
tobj.addProperty("id", ConditionType.EQUALS, "qa-5",true)

The log to me is
2019-08-22 13:33:33.993 DEBUG testcase.click - 6: println(tobj.getObjectId())
testObject
2019-08-22 13:33:33.999 DEBUG testcase.click - 7: tobj.addProperty(“id”, EQUALS, “qa-5”, true)
2019-08-22 13:33:34.001 DEBUG testcase.click - 8: println(tobj.getObjectId())
testObject
2019-08-22 13:33:34.003 DEBUG testcase.click - 9: println(MessageFormat.format(CONF_PROPERTY_EXECUTION_SOURCE_ID, tobj.getObjectId()))
id

But the id should be what I set as “qa-4.”
Thanks.

Hi,
Use

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

TestObject tobj = new TestObject('testObject')
tobj.addProperty('id', ConditionType.EQUALS, 'qa-4', true)
println tobj.findPropertyValue('id')
WebUI.modifyObjectProperty(tobj, 'id', 'equals', 'qa-5', true)
println tobj.findPropertyValue('id')
1 Like

Thanks , it works.