Hi there,
How can I validate a value and also extract other values from a single response in websocket ??
Here is my request event to login.
exec(
ws(“login to our websocket service”)
.sendText("""{“event”:“login”,“username”:“foo”,“password”:“bar”}""")
.check(wsAwait.within(10 seconds).until(1).jsonPath("$.event").is(“authenticated”))
)
The following events would be returned as a response to the login event above.
{“event”:“authenticated”, “result”:“true”, “userId”:123}
or
{“event”:“authenticated”, “result”:“false”}
What I want to do is that if the event name is “authenticated” and the result attribute is “true” then,
I want to save a value of the userId attribute into a session.
I did like the following at the first but since there’re two wsAwait, the gatling expects two separate events…hm.
exec(
ws(“login to our websocket service”)
.sendText("""{“event”:“login”,“username”:“foo”,“password”:“bar”}""")
.check(wsAwait.within(10 seconds).until(1).jsonPath("$.event").is(“authenticated”))
.check(wsAwait.within(10 seconds).until(1).jsonPath("$.userId").saveAs(“userId”))
)
How can I validate and save values at the same time in a single response (websocket event) ??
Or is there a workaround ?
Thanks a lot.
Wolfgang