Unable to verify element property value

When I test the test object by itself, it gets the response header as below -

HTTP/1.1 200 OK
Server: Microsoft-IIS/7.5
Cache-Control: private
Access-Control-Allow-Origin: *
Connection: keep-alive
X-AspNet-Version: 4.0.30319
Content-Length: 181
Date: Wed, 16 Jan 2019 17:59:33 GMT
X-Powered-By: ASP.NET
Content-Type: application/json; charset=utf-8

However, If I create the test case and execute it, it is throwing the following error -

01-16-2019 07:11:37 PM Test Cases/ProofOfConcept

01-16-2019 07:11:41 PM println("getContentType: " + response.getContentType())

Elapsed time: 0.160s

println("getContentType: " + response.getContentType()) FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: response for class: Script1547660508279
at ProofOfConcept.run(ProofOfConcept:17)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1547691093050.run(TempTestCase1547691093050.groovy:22)

Please share your testcase.

Please find the test case screen capture -

Here is the code -

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

println ("getContentType: " + response.getContentType())

response = WS.sendRequest(findTestObject(‘POST-UrlGetInfoCopy’, [(‘url’) : url]))
println (“url is sent”)

WS.verifyElementPropertyValue(response, [(‘queries.getinfo.cats[0].catid’), category])
println (“category is received.”)

You can not refer to the response variable before you create it. Change the code as follows, and try again.

So sorry about that, I have corrected it and ran the test case. Here is the console log -

SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
2019-01-16 19:29:06.908 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[39m--------------------e[0;39m
2019-01-16 19:29:06.917 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[39mSTART Test Cases/ProofOfConcepte[0;39m
2019-01-16 19:29:08.133 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[39m(Default) url = google.come[0;39m
2019-01-16 19:29:08.169 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[39m(Default) category = 50e[0;39m
2019-01-16 19:29:10.818 e[39mDEBUGe[0;39m e[36mtestcase.ProofOfConcept -e[0;39m e[39m1: response = sendRequest(findTestObject(“POST-UrlGetInfoCopy”, [“url”:url]))e[0;39m
2019-01-16 19:29:13.963 e[34mINFO e[0;39m e[36mc.k.k.core.util.BrowserMobProxyManager -e[0;39m e[39mHAR: C:\Users\SPULLA~1\AppData\Local\Temp\Katalon\Test Cases\ProofOfConcept\20190116_192901\requests\main\0.hare[0;39m
2019-01-16 19:29:14.409 e[39mDEBUGe[0;39m e[36mtestcase.ProofOfConcept -e[0;39m e[39m2: println(“url is sent”)e[0;39m
url is sent
2019-01-16 19:29:14.513 e[39mDEBUGe[0;39m e[36mtestcase.ProofOfConcept -e[0;39m e[39m3: println("getContentType: " + response.getContentType())e[0;39m
getContentType: application/json; charset=utf-8
2019-01-16 19:29:14.587 e[39mDEBUGe[0;39m e[36mtestcase.ProofOfConcept -e[0;39m e[39m4: verifyElementPropertyValue(response, [“queries.getinfo.cats[0].catid”, category])e[0;39m
2019-01-16 19:29:14.712 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ verifyElementPropertyValue(response, [“queries.getinfo.cats[0].catid”, category]) FAILED.e[0;39m
e[31mReason:e[0;39m
e[31mgroovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyElementPropertyValue() is applicable for argument types: (com.kms.katalon.core.testobject.ResponseObject, java.util.ArrayList) values: [200 3 KB, [queries.getinfo.cats[0].catid, 50]]e[0;39m
e[31mPossible solutions: verifyElementPropertyValue(com.kms.katalon.core.testobject.ResponseObject, java.lang.String, java.lang.Object), verifyElementPropertyValue(com.kms.katalon.core.testobject.ResponseObject, java.lang.String, java.lang.Object, com.kms.katalon.core.model.FailureHandling)e[0;39m
e[31m at ProofOfConcept.run(ProofOfConcept:22)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)e[0;39m
e[31m at TempTestCase1547692141957.run(TempTestCase1547692141957.groovy:22)e[0;39m
2019-01-16 19:29:15.039 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ Test Cases/ProofOfConcept FAILED.e[0;39m
e[31mReason:e[0;39m
e[31mgroovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyElementPropertyValue() is applicable for argument types: (com.kms.katalon.core.testobject.ResponseObject, java.util.ArrayList) values: [200 3 KB, [queries.getinfo.cats[0].catid, 50]]e[0;39m
e[31mPossible solutions: verifyElementPropertyValue(com.kms.katalon.core.testobject.ResponseObject, java.lang.String, java.lang.Object), verifyElementPropertyValue(com.kms.katalon.core.testobject.ResponseObject, java.lang.String, java.lang.Object, com.kms.katalon.core.model.FailureHandling)e[0;39m
e[31m at ProofOfConcept.run(ProofOfConcept:22)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)e[0;39m
e[31m at TempTestCase1547692141957.run(TempTestCase1547692141957.groovy:22)e[0;39m
2019-01-16 19:29:15.170 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[39mEND Test Cases/ProofOfConcepte[0;39m

Looks like some weird characters printed with the console log.

The ContetType you received is “application/json; charset=utf-8”; this is OK.

WS.verifyElementPropertyValue(response, [(‘queries.getinfo.cats[0].catid’), category])

Here you are passing an instance of java.util.List as the 2nd param. This is wrong. As document describes, the 2nd and the 3rd argument to the verifyElementPropertyValue should be String.

Change your code as follows and try again:

WS.verifyElementPropertyValue(response, 'queries.getinfo.cats[0].catid', category)

This is a known problem. See

I have tried per the document before and it did not work. So I have tried the way I posted earlier.

But now, I have changed per your suggestion again back to the one described in the document and I am getting the Null Pointer exception as below -

01-16-2019 08:24:51 PM verifyElementPropertyValue(response, “queries.getinfo.cats[0].catid”, category)

Elapsed time: 0.271s

Unable to verify element property value (Root cause: java.lang.NullPointerException: Cannot get property ‘getinfo’ on null object)

Sorry, I have no more idea.

It is difficult to investigate without immediate access to the AUT.

I understand. How can I do that ?

We are trying to do a proof of concept to purchase the Katalon tool.
I need to at least build GET, POST, PUT, DELETE calls, so I am trying my best. I like the tool but just really trying to figure out how it can help our team.

By the screenshot of you Test Object POST-UrlGetInfoCopy, I have got to know the URL of your AUT is
http://api-qa.bcti.bd.com/1.0/?

When I try to browse this URL, I got ERR_DNS_FAIL. This means the hostName api-qa.bcti.bd.com is not known public.

Can you make this URL (or its equivalent one) publicly accessible via Internet?

This is actually the modified one, since I cannot post the original one since I do not know if I can post the original one. I can ask my higher ups, If I can do that. Kindly wait until I get a nod from them.

I am sorry, I couldn’t get a nod to post it openly in the forum. Thank you very much and Appreciate your help. However, I will keep trying to see in this forum, if someone has the same problem.

Hi, I’m having a very similar issue. has anyone resolved this issue?!

@amohan

Please have a look at the following guidance

I would recommend you to create a new discussion for your issue.

@kazurayam Thanks for the reply

Is it because there needs to be a trailing . following the json locator?

WS.verifyElementPropertyValue(response, 'data.', 'verificationStatus')

See that there’s a trailing . at the end of 'data.

Hi, I am facing a problem setting the Element locator for my JSON data. Code and JSON data are given below. Can any one help me here ?
Code***************************************
response = WS.sendRequest(findTestObject(‘From my object repository’))
WS.verifyResponseStatusCode(response, 200)
WS.verifyElementPropertyValue(response, ‘result.resultCode’, ‘SUCCESS’)
JSON Data******
{
“result”:{
“resultStatus”:“S”,
“resultCode”:“SUCCESS”,
“resultMessage”:“success”
},
“authExpiryTime”:“2021-08-15”,
“paymentId”:“123456”
}