我有以下代码。问题是没有为随后的请求设置 cookie。
我想设置一个由所有后续请求(包括 ajaxRequests
)使用的 cookie。
val get = scenario("Page")
.feed(myfeed)
.group("Home Page") {
exec(session => setSessionVariables(session))
.exec(addCookie(Cookie("mycookie", "true").withDomain(baseurl)))
.exec(http("Home Page")
.get(pageUrl)
.resources(
ajaxRequest01,
ajaxRequest02
))
}
最佳答案
我最好的猜测是这里的问题是您使用的 baseUrl 包含协议(protocol) - 例如https://www.google.com/等等
根据我对此功能的实验,这行不通,cookie 只需要传递域 - 例如www.google.com 或只是 .google.com 如果您希望它跨子域应用。
关于scala - 如何为 Gatling 场景设置 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47515341/