4
votes

I am using Gatling 2.1.7 and I cant't find a way to check multiple values with JsonPath.

Lets pretend I have this Json:

{
  "messageTyp": "wsopen",
  "userId": "1" 
}

I do need to check both values. It is easy to check on of the values:

.check(wsAwait.within(2).expect(1).jsonPath("$..messageType").is("wsopen"))

But because this tests are running in a "feeder"-loop, there are a lot "wsopen" messages, coming back asynchronous. I need to check, that every user receives exactly one "wsopen" message.

I need something like

.check(wsAwait.within(2).expect(1).jsonPath("$..messageType").is("wsopen").and.jsonPath("$..userId").is("${userid}")) // won't compile

Anybody a hint?

1

1 Answers

4
votes

You can do it with JSONPath directly:

jsonPath("$[?(@.messageTyp=='wsopen' && @.userId=='1')]").exists