private val scn = scenario("RAPtest")
.exec(
http("Home")
.get("/")
)
.pause(2) .exec { session =>
session.set("sessID",getCookieValue(CookieKey("PHPSESSID")).toString)
}
.exec( http("request_23")
.patch("/api/v1/resource/#{sessID}\"/1")
.headers(headers_23)
.body(StringBody(s"""{ "op":"replace",
"path":"/Login/#{sessID}/Login/#{sessID}}/Userid",
"value":"stefj"
} """)).asJson
.resources(
http("request_25")
.get(s"/api/v1/resource/#{sessID}/1/Login")
.headers(headers_2)
)
)
```
I hope it is clear what I want. After getting the home page, there is a cookie (named "PHPSESSID"), which contains the session id.
I want to store the value of that cookie in a variable, sessID, to be used in request-23. Nothing I tried has worked. The attempt shown above seems to come closest.
11:42:36.301 [DEBUG] i.g.h.e.r.DefaultStatsProcessor - Request 'request_23' failed for user 1:
status.find.in(200,201,202,203,204,205,206,207,208,209,304), found 500
11:42:36.303 [TRACE] i.g.h.e.r.DefaultStatsProcessor -
>>>>>>>>>>>>>>>>>>>>>>>>>>
Request:
request_23: KO
status.find.in(200,201,202,203,204,205,206,207,208,209,304), found 500
=========================
Session:
Session(RAPtest,1,HashMap(gatling.http.cache.baseUrl ->
https://rap.cs.ou.nl, gatling.http.ssl.sslContexts -> io.gatling.http.util.SslContexts@6ff2cb79, gatling.http.referer ->
https://rap.cs.ou.nl/, gatling.http.cookies -> CookieJar(Map(CookieKey(phpsessid,
rap.cs.ou.nl,/) -> StoredCookie(PHPSESSID=1e9dd7d883a2c639033b7dcf820a7fc8, path=/, HTTPOnly,true,false,1640256156289))), sessID -> io.gatling.http.action.cookie.GetCookieBuilder@ed9e8cf, gatling.http.cache.dns -> io.gatling.http.resolver.ShufflingNameResolver@21be0fe2, gatling.http.cache.contentCache -> io.gatling.core.util.cache.Cache@624cafb4),KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$555/0x000000080108b170@7a9a5dd0,io.netty.channel.nio.NioEventLoop@344561e0)
=========================
HTTP request:
PATCH
https://rap.cs.ou.nl/api/v1/resource/io.gatling.http.action.cookie.GetCookieBuilder@ed9e8cf%22/1Instead of a string with the session id, I get the string "io.gatling.http.action.cookie.GetCookieBuilder@ed9e8cf".