[Gatling 2.2.3] Perform either/or check on http response


First of all, thanks for this rocking piece of software.

Now, I’m struggling at dealing with a use case which is so simple that I may have missed something obvious - but after scouting the docs, examples and topics in this group multiples times, I’m still in the dark.

The http response that I’m considering contains a piece of data located either in an item (a div) or another one (a string), and I want to assert that this data is a specific value.
In other words, I would like to express something like the pseudo example below:
http(…).checkOneOf( css("#id").is(“value”), regex(""“mypattern(capture)”"").is(“value”) )

Obviously, checkOneOf does not exist. :slight_smile:
I’d like the check to fail only if none of the check passed.

Is there any way to achieve this?

Pascal D

have you tried css("#tag").in(“foo”, “bar”) ?

have you tried css("#tag").in("foo", "bar") ?

That's the other way around: I need sthg like (css("#tag") or regex("pattern")).is("foo")


one way to tackle it down would be to use conditional check, namely “checkIf”:

The 1st “checkIf” could be fired only if the 1st condition is not met and would check the 2nd condition, and the 2nd “checkIf” could be fired only if the 2nd condition is not met and would check the 1st condition. Sort of gimmicky, but should work :slight_smile:

You can access the response inside “checkIf” like this:


val responseIsValid: (Response, Session) => Validation[Boolean] = {
(response: Response, _) => response.statusCode.contains(200)



Ah ok, should work indeed. Not as compact as I would have loved to, but that should do it.