Forum Discussion
$.accessToken should equal to the desired value.
- mgroen29 years agoSuper Contributor
nmrao wrote:
For the mentioned case, JsonPatMatch is fine.
$.accessToken should equal to the desired value.nmraoI entered this (see screenshot), but it's not working. as you can see there is an accesstoken in the response, but validating it gives an error (it thinks it should be false?). Do you have any tips?
- HKosova9 years ago
Alumni
mgroen2, you're using JsonPath Regex Match. Try the regular JsonPath Match instead.
- mgroen29 years agoSuper Contributor
Hi,
HKosova as you suggested, I implemented the JsonPath Match,
the strange this is, that validation initially succeeds (I clicked on "select from current"), however when re-executing the test it fails, and the reason for that is that expected value is changed, a comma is added to the end (see second screenshot).
After re-selecting the value again (" select from current"), the assertion passes again first time, but re-executing the test, makes the assertion fail again (comma is added again). Is this known behaviour? Possibly a bug?
- nmrao9 years agoCommunity HeroYou should be able to try here
http://jsonpath.com/
Following Script Assertion should help:
def parsedJson = new groovy.json.JsonSlurper().parseText(context.response)
log.info parsedJson.accessToken
//replace expectedValue below
assert expectedValue == parsedJson.accessToken, 'Not matched.'
You can also check here:
http://groovyconsole.appspot.com/script/5179916383420416