gatling - getCookieValue 返回一个对象
问题描述
我已经使用 getCookieValue() 方法从会话中获取 cookie 值,它返回一个对象 io.gatling.http.action.cookie.GetCookieValueBuilder@2012cf26
.exec{session => {
val cookie = getCookieValue(CookieKey("CookieKey"))
println("Session cookie is :::::::::::::::::::::::::" + cookie.toString)
session
}}
应该获取 cookie 值而不是 io.gatling.http.action.cookie.GetCookieValueBuilder@2012cf26
解决方案
查看文档,getCookieValue 是一个 DSL 操作(正如您所发现的),它返回一个构建器,因此您需要在“执行”块中执行它 - 它旨在获取命名 cookie 并将其放入会话中。
所以如果你这样做了
.exec(getCookieValue(CookieKey("CookieKey")))
名为“CookieKey”的 cookie 的值将放在会话中的键“CookieKey”下。
您不能在会话函数中调用 DSL 方法 - 返回的构建器永远不会被调用
推荐阅读
- data-structures - 需要帮助来理解默克尔树
- amazon-web-services - AWS 多 VPC VPN 共享可能性
- python - 获取不同类的值
- c++ - c++中输入参数的正确形式
- javascript - Safari 阻止 video.js 播放器的自动播放
- regex - 什么是 url-validation 正则表达式,它的用途是什么?
- asp.net-core - asp.net 核心创建/更新外键
- react-native - 通过 rn-fetch-blob 下载图像后,iOS 设备中未显示图像(React native fetch blob)
- laravel - 无法从 Laravel 控制器分页
- php - Symfony 2:是否可以在 YAML 文件中导入 PHP 文件?