简体   繁体   中英

Gatling: Get cookie value with Gatling 2

Hi I want to extract a value from a cookie and pass that cookie value as a parameter to the next exec(). I found some syntax which does not work for the new Gatling 2. Could someone please show an example?

Thanks

在 Gatling Goole Group 上回答:从“Set-Cookie”标题中使用正则表达式提取:

.check(headerRegex("Set-Cookie", "yourRegexHere").saveAs("attributeName"))

Gatling can deal directly with cookies. This copies the JSESSIONID cookie in the session from which it can be retrieved.

exec(getCookieValue(CookieKey("JSESSIONID").withPath("/ApplPath")))
exec(session => "JSESSIONID=" + session("JSESSIONID").as[String]; session)

See Gatling current documentation https://gatling.io/docs/current/http/http_helpers/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM