0
votes

I'm trying to save information from a websocket answer in an attribute. I need to wait for this, because i can't proceed the test without it. But my check always times out.

This is the answer from the websocket:

4{"cid":1337,"data":{"id":"54f81d216bae58670c070b57","isActive":true,"unreadCount":0,"sharedImages":[],"lastUpdateDate":{},"chatPartner":{"id":"5422667125d54ee17c8b4567","username":"demoUser","gender":"m","isOnline":false,"common":0,"age":25}}}

This is my regex pattern:

"\"cid\":1337,\"data\":\\{\"id\":\"(.+?)\".*"

This is my WScheck:

.check(wsAwait.within(10 seconds).until(1).regex(pattern).saveAs("conversationId"))

Did I miss something?

1

1 Answers

0
votes

I won't personally waste time on fixing your regular expression, and you shouldn't either. Gatling provides JsonPath based checks. With this, your check would simply be:

.check(wsAwait.within(10 seconds).until(1).jsonPath("$.data.id").saveAs("conversationId"))