Is a testobject is mandatory as an argument for api custom keywork

I am trying to create some api custom keywords. When I am creating api keywords by passing the testobject as an argument it’s working fine but while I am not passing testobject as an argument in that case it’s not working.

CustomKeywords.‘cam.template.ManageProfile.createToken’(findTestObject(‘create_token’),
GlobalVariable.camUrl) – Working fine

CustomKeywords.‘cam.template.ManageProfile.getProfileId’(token) - Not working as I am not passing the test object, here token is a string value

Below is the code for getProfileId keyword:

RequestObject request = (RequestObject) findTestObject(‘get_tenant_id’, [(‘accessToken’) : token])
ResponseObject response = WS.sendRequest(request)

I am getting below error.

groovy.lang.MissingMethodException: No signature of method: cam.template.ManageTemplate.findTestObject() is applicable for argument types: (java.lang.String, java.util.LinkedHashMap) values: [get_tenant_id, [accessToken:666gggggghh]]
07-23-2018 06:20:03 PM - [ERROR] - Test Cases/UsingKeywords/TC1_create_barear_token FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: cam.template.ManageTemplate.findTestObject() is applicable for argument types: (java.lang.String, java.util.LinkedHashMap) values: [get_tenant_id, [accessToken:666gggggghh]]

Will be happy if anyone can help me in this issue, waiting for positive response.

can you please post whole definition of cam.template.ManageTemplate.findTestObject() and definition of cam.template.ManageProfile.getProfileId()

Sudhir Mohanty said:

I am trying to create some api custom keywords. When I am creating api keywords by passing the testobject as an argument it’s working fine but while I am not passing testobject as an argument in that case it’s not working.

CustomKeywords.‘cam.template.ManageProfile.createToken’(findTestObject(‘create_token’),
GlobalVariable.camUrl) – Working fine

CustomKeywords.‘cam.template.ManageProfile.getProfileId’(token) - Not working as I am not passing the test object, here token is a string value

Below is the code for getProfileId keyword:

RequestObject request = (RequestObject) findTestObject(‘get_tenant_id’, [(‘accessToken’) : token])
ResponseObject response = WS.sendRequest(request)

I am getting below error.

groovy.lang.MissingMethodException: No signature of method: cam.template.ManageTemplate.findTestObject() is applicable for argument types: (java.lang.String, java.util.LinkedHashMap) values: [get_tenant_id, [accessToken:666gggggghh]]
07-23-2018 06:20:03 PM - [ERROR] - Test Cases/UsingKeywords/TC1_create_barear_token FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: cam.template.ManageTemplate.findTestObject() is applicable for argument types: (java.lang.String, java.util.LinkedHashMap) values: [get_tenant_id, [accessToken:666gggggghh]]

Withdrawing this post, as it was due to my mistake. I was not importing the below package hence it was not working. After importing it’s working fine for me.

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

1 Like