How I can use JSON Path assertion for two different strings without using Groovy
I have a JSON Path assertion which expecting a string like "PAYMENT REVERSED" but sometimes the string also can be "PAYMENT REVERSAL". Is it possible to do as follows? (tried but didn't work) or what is the best way to do this?
PAYMENT REVERSED || PAYMENT REVERSAL
I tried the JSONPath Regx match assertion as well but didn't work. Help much appreciated.
Solved! Go to Solution.
I understand a reluctance relying on coding if you're not a coder (or if managers dont want to include code when considering future maintenance, etc.) - but adding a small 2 line script assertion would resolve this problem.
Also - considering that the two possiible values are PAYMENT REVERSED and PAYMENT REVERSAL, wouldnt they have identical regex patterns anyway?
a while back I had to assert that a certain json value had either of 2 values and @nmrao supplied me the following Script Assertion:
//courtesy of Rao
def jsonResponseContent = new groovy.json.JsonSlurper().parseText(context.response) assert jsonResponseContent.parentattribute.childattribute == ['PAYMENT REVERSED' || 'PAYMENT REVERSAL']
As I say - I know you say you dont want to use groovy script - but it's a two line script assertion - anyone reading this (even with zero groovy) would be able to understand what the code is actually doing.
If you're still struggling with the JSON Regex match assertion - perhaps the above might help you?
Just a suggestion, cheers,