Forum Discussion
- JHuntCommunity Hero
Get hold of the whole value using XPath (Xpath assertion, script assertion), XmlSlurper (script assertion), Regular Expression (contains assertion, script assertion), JsonPath (JsonPath assertion), JsonSlurper (script assertion).
Then just make a direct comparison.
However, if you want a specific answer, please ask a specific question. What format is your data in? Can you give an example (i.e. an entire response message) that should match and one that shouldn't match?
- reyaz079New Contributor
Hi,
I get response in json format (REST API)
- JHuntCommunity Hero
assert new groovy.json.JsonSlurper() .parseText(messageExchange.responseContent) .find {it.key == "abc" && it.value == 123}
- reyaz079New Contributor
I have a doubt here, i need to add a groovy script step here, and need to add content given by you. Or directly i can keep it either contains or Not Contains assertion section
- JHuntCommunity Hero
Above is for script assertion.
- AABRegular Contributor
Thanks for helping out. But for me this script isn't working completely as I would. Could you help me out please?
I'm working with REST request with responses in JSON. If I use this Script Assertion it fails because there are other values present. So this is great! BUT:
The error message is just throwing me the whole response content. I would expect that the script just tells me which values shouldn't be in there. So actually something like:
if you found anything else then IT
show this in the Script assertion error message.
Is this possible please? Or maybe even in a popup. Is also cool....
Thanks in advance for looking into this.
Kind regards,
AAB
Related Content
- 9 years ago
- 8 years ago
- 5 years ago