用于 inferHtmlResources 的 Cookie

Cookies for inferHtmlResources

我想使用 Gatling 测试我是否可以访问 html 资源。 为了访问给定 HTML 及其资源,我必须定义一些 cookie。

我可以使用简单的 .header("Cookie","test=test") 在 http 调用中设置 Cookie,但那样的话,它不会将 cookie 设置为推断的资源。

根据文档,您应该能够将 cookie 设置为:

One might want to manually add or compute a cookie:

exec(addCookie(Cookie("name", "value")))

但像这样使用时对我来说根本不起作用:

val someScenario = scenario("scenario").exec(
    exec(addCookie(Cookie("test","test"))),
    exec(http("httpcall").get("someUrl")))

有没有办法为 inferHtmlResources 设置 cookie?

Cookie 绑定到域。如果你不指定 withDomain,Gatling 将使用 HttpProtocol baseUrl 之一,如果没有则崩溃。因此,一个可能的解释是此默认域与您的资源之一不匹配。如果是这种情况,请在您的 cookie 上设置一个正确的域。

否则可能是bug。查bug tracker, upgrade your Gatling version if you use an old one (as you don't specify the version you're using, which is bad), and give the latest snapshot试试看。如果没有任何效果,请打开一个问题,您可以在其中提供重现方法。