Multiple saveAs on ws.sendText

Hi all,

I looked through the topics for how to save multiple jsonPath values from a web socket response and found a few answers.

  1. Using multiple (see below) checks give me "too many arguments for method check". Maybe vargars for check is gone ?

.sendText( “”"{ “action”:“start” }""")


  1. Doing .check(…).check(…) etc fails to save anything but the last which I assume after reading forum is due to the immutability ?

Any other solution / tips on how to save multiple jsonPath results from a json response on a web socket ?



No, setting multiple checks on websockets is not currently supported.

It’s very complex actually. What would the behavior be? Wait until all of them get resolved? Keep going as soon as one gets resolved but fail the other ones? Try to keep on resolving them in the background? Would the answer to this question be generic enough, or is it specific to your use case?


No you are absolutely right, the semantics with multiple checks just doesn’t make sense. I think I managed to confuse us both. :slight_smile:

I’m not really looking for multiple checks, rather saving multiple parts of the json response.

Here is an example response:

Also I should let you know that my Scala experience sums up to about 1,5 weeks so please be gentle with assumptions. :slight_smile:

For instance I’m not sure what Right(Vector()) actually means. I assume it’s a vector that I can iterate
over and get to the actual values somehow.


Ok, so this is my solution. I’m guessing there are better ways of doing this, but this is what I came up with

val sendConnect = exec(ws(“Send Connect Action”)
“control”: {
“type”: “request”,
“header”: {
“action”: “connect”
).exec { session =>

val connectResponse = session(“connect_response”).as[String]
val json = (new ObjectMapper).readValue(connectResponse, classOf[Object])
val initiator = JsonPath.query("$.header.initiator", json)
val session_id = JsonPath.query("$.control.session_id", json)

val initiatorVal = initiator.right.get.head
val sessionVal = session_id.right.get.head
val newSession = session.set(“initiator”,initiatorVal).set(“session_id”,sessionVal)

Feel free to comment as I feel this isn’t the most elegant solution out there. For instance the complete response message is stored
in the session along with the subparts of it.


I have the same problem.
I would like to save some other JSON property that I am not checking for.

More concretely:
I want to check if the “requestId” property matches but I want to save the “sessionId” property of the message.

It would be cool if there is a “save” method which gives you access to the complete message which contained the match and not only to the path which is specified via “jsonPath” or “jsonpJsonPath”

We’ll bring a new WebSocket API in Gatling 3.
Progress and discussion happens here:
What you’re mentioning is what we currently call “matching”.
Note that milestones of the next versions are only available to our support offer subscribers.