I have a web service that returns an array, and I’m trying to verify that the array contains a particular value as a check (Gatling 1.x). The array is the entire response (it’s the root element).
I’m quite new to gatling so I’m having issues getting this to work. What I’ve tried is
check(jsonPath("$_").contains(“someValue”))) // the check is chained to the rest of the exec call
I’m getting an error that says error: value contains is not a member of com.excilys.ebi.gatling.http.check.HttpMultipleCheckBuilder[String]. I’m guessing this is happening because jsonPath doesn’t return an array, but I’m not sure what the correct syntax is for this.
If you want to collect all the values, the correct path is “$…*”. However, we don’t currently have a “contains” check. The reason is that we expect users to do this filtering in the expression.
So, what you have to do is design a proper JsonPath expression that will only succeed when your condition regarding “someValue” holds, and use the regular/default “exists”.
Thanks for the quick reply. The reason I was trying the underscore was from a note on the gatling wiki page that says
In JSON, the root element has no name. This might be a problem when it’s an array and one want to target its elements. As a workaround, Gatling names it _.
Am I misunderstanding what that means?
But to the rest of your reply, that makes sense. I’ll give that a try - thanks again.