Error when using WS.sendRequest

In a test case I want to do this:

In <what to put here?> it had response variable but I get the following error:

Do you know what could it be?

Hi @diogo.soares,

The details about how to use WS.verifyElementPropertyValue(…) is available here. And if in case, the document is still not enough, here is the sample code base on your script to help you get started easier /=)

import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.model.FailureHandling as FailureHandling

ResponseObject response = WS.sendRequestAndVerify(findTestObject('ServiceNow - GET test suite'))

if (WS.verifyElementPropertyValue(response, 'result[0].name', GlobalVariable.testSuiteName, FailureHandling.OPTIONAL)) {
    println('already exists')
} else {
    WS.sendRequest(findTestObject('ServiceNow - POST test suite'))

Remember to put FailureHandling.OPTIONAL as the fourth parameter of the call to WS.verifyElementPropertyValue(…). Otherwise, your script will be stopped immediately after a failed verification /=).

Hello @thongnmtran

I keep getting the same error. The problem here is that sendRequestAndVerify doesn’t return anything and in verifyElementPropertyValue it is needed an object.


if (WS.verifyElementPropertyValue(response, ‘result[0].name’, GlobalVariable.testSuit

…the given response is empty or null and so result[0].name cannot resolve it on a null value.

I’m stuck :frowning:

Hi @diogo.soares ,

Oh, I missed that. Have you try with WS.sendRequest(…). Or maybe you could double-check your response object by print it out into the console log

import com.kms.katalon.core.util.internal.JsonUtil

println " - - - "
println JsonUtil.toJson(response, true)
println " - - - "

Yes, with sendRequest happens the same.

When I send a request with the GET I mentioned before, it will query for a specific param:

And it will not find at the source because the record I’m looking for doesn’t exist in the source. And it shouldn’t, that is correct. So I receive this:

2020-05-06 09:49:00.266 DEBUG testcase.01 - Create Test Suite - 2: println(toJson(response, true))
“contentType”: “application/json;charset\u003dUTF-8”,
“responseText”: “{"result":[]}”,


However, an error shouldn’t be thrown because I’m consider in my code that will happen. Am I right?