Gatling Check for logical operation like and & Or

How to check value of a parameter that either match with value “abc” or “xyz” in gatling. How to check for logical Or & And?

Something like

.check(jsonPath($"abc" || "xyz")

You can try following:

.check(jsonPath("$..totalCount").in("14303" , "234")

I have other problem to perofrm check on 2 different parameters to pass the test case like below. how to do this?

.check(jsonPath($..fname).is("abc") || .check(jsonPath($..lname).is("xyz")

.check(jsonPath("$…fname").is(“abc”), jsonPath("$…lname").is(“xyz”))


Thanks Nikoyay, It’s returning false if and test is failing if one of the value is not satisfied. Like fname is abc and lname is def then my test case need to pass.

Hi Raj,
not sure if lname check is needed in this case
If test should pass with its any value you can just add .exists check

Yes lname needed. In API we query on 2 fields using OR. So result set will include records matching either fname or lname. How to add exists in this case?

So you should check that lname exists but it could have any value?

No Nikolay, I need to check the value too. But I need to pass the test cases if either one matches. Just like normal if condition like if(fname=“abc” || lname=“xyz”) which returns true. Same I need to put this logic in gatling check.

You can use
doIfOrElse(fname==“abc” || lname==“xyz”)