How I can use JSON Path assertion for two different strings without using Groovy
- 6 years agoYou could try using regex.
For more details:
https://stackoverflow.com/questions/28954720/jsonpath-expression-to-filter-using-regex - 6 years ago
Hi mpw83
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,
rich