scala - 如何为 Gatling 场景设置 cookie

标签 scala gatling scala-gatling

我有以下代码。问题是没有为随后的请求设置 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/

相关文章:

scala - 使用 Gatling 进行调试 - 如果状态为 500,则打印 ln

scala - 我如何将Either 推广到更多(和递归)类型?

performance - Scala 中 curried、部分应用和 'normal' 函数之间的性能特征是什么?

scala - 加特林负载测试和运行场景

performance-testing - Gatling(性能测试):how to perform task in background every x-minutes

特定时间段内固定用户数的加特林模拟

scala - 使用 Gatling 和 Content-Type 进行负载性能测试

scala不喜欢akka中的自变量?

scala - 在 Scala 中创建映射字符串 -> 函数

scala - 获取错误 : There is no simulation script. 请检查您的脚本是否在用户文件/模拟中按任意键继续。 .