OR clause in Gatling check verifier

Hi,

Currently my script implements the check as below to verify JSON response

.check(regex("“status”:1").exists)

Now one of the requests return status 1 or status 6 depending on the work flow.

Both are valid responses.

Is there a way to implement a check with OR clause and declare it a pass if either value(s) is found.

Regards,

Megha

Hi Megha,

Looking at your regex I assume that you checking some json response.
You can use JsonPath expression and save result to session (see http://gatling.io/docs/2.1.7/http/http_check.html):

.check(jsonPath("$.status").exists.saveAs(“status”))

Then you can use session api to access to the “status” variable and make doIfOrElse or switch.

doIf (session => session.get(“status”).as[String], “1”) {

}

Thanks,
Alex.

Thanks Alex for the idea of using JsonPath expression.
Changed the check to the following and it works like a charm!

.check(jsonPath("$.status").in(“1”,“6”))

Regards,

Megha