how to put assertion, if i want only exact match, eg 42,then if response contain 142, it should fail
Hi SmartBear Team,
I have to put contain assertion with any no. value or text , and my requirement is, it should pass only if that number or text exact match.
For example if i need 42 or "ear" in response, and response contain 142 or "early". Then it should fail.
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?
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
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.