verifyElementPropertyValue

I’m facing a weird and interesting issue with the keyword -verifyElementPropertyValue.
I try to verify a property value from the REST response and for some reason only the FIRST character of the
actual value of the field is read and therefore the validation fails.

For E.g.,
Srtring accountId = B000000
my response also has ‘accountNumber = B000000’

Now consider → verifyElementPropertyValue(getResponse, “accountNumber[0]”, accountId)

this fails with an error saying :x: Expected element property value ‘B000000’ is not equal with actual property value ‘B’.

Note : I’m using the version 6.2.1 and my previous scripts with the same keyword are working fine.
Kindly help.

Hi @amohan,
Can you share your whole response?
Regards.

Hi @huynguyen, I wont be able to post the entire response here but below is the part you might be looking for,

“text” : "{“accountClass”:“Estates”,“accountNumber”:“B000000”,“accountStatus”:“Active”,“accountSubType”:“NotSet”,…}

Hi @amohan,
Please remove the index [0] from your locator

1 Like

That worked. Thanks!

Hi,
I’m having issues with keyword verifyElementPropertyValue too. Sometimes my test case fails and sometimes it does. The error I’m getting is:

Unable to verify element property value (Root cause: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: [ @ line 1, column 93.
rseText(jsonText);return root.[null].emp
^

1 error

at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper.parseAndGetPropertyValueForJson(WebServiceCommonHelper.java:162)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.doCall(VerifyElementPropertyValueKeyword.groovy:52)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.call(VerifyElementPropertyValueKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.verifyElementPropertyValue(VerifyElementPropertyValueKeyword.groovy:48)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.execute(VerifyElementPropertyValueKeyword.groovy:43)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:72)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyElementPropertyValue(WSBuiltInKeywords.groovy:189)
at Verify DV highlight a genuine failure for error-codes.run(Verify DV highlight a genuine failure for error-codes:60)
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:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1592362928250.run(TempTestSuite1592362928250.groovy:37)

)
Sample JSON Response is:
[
{
“empno”:“emp01”,
“errorCode”:“ERR-001”
},
{
“empno”:“emp02”,
“errorCode”:“ERR-002”
}
]
my code is something like this:
verifyElementPropertyValue(response, ‘[1].errorCode’, errorCode)

The value for the variable errorCode in my test data have hyphen e.g. ERR-001.

Thanks for your help