I am using gatling 2.3.1 version.
I have to verify that json response from a request contains correct value. I could not use check(status.is(200)) because even if json response has inc correct data request returns status code as 200.
I have tried following code-
doIfEquals("${myVal}","${val}"){
exec(http(“do something”))
}
Help much appreciated
You can use jsonPath checks:
.check(jsonPath(“yourJsonPathExpression”))
Hi Katerina,
Let me try to explain what I am trying to do…
- We call 1 post request to this we pass json as {“username” : “abc”, “password” : “abcdef”}
- now in next get request returns us json, which is like{ “id”:13231… {“username” : “abc”, “email” : “xxx@xxx.com”} … }
- we have to check that logged in user name that we have passed and which we get in the next request are same or not.
Thanking in advance.
I think you can use a String using Gatling EL in jsonPath as well in other types of checks.
So, assuming you have your username in a session variable, you can use this variable in jsonPath expression or another type check expression.
I haven’t tried it myself, but there is at least a regex example in documentation (https://gatling.io/docs/2.3/http/http_check/):
regex("""<td class="number">ACC${account_id}</td>""")
where ${account_id} is a session variable