【发布时间】:2020-09-29 15:06:56
【问题描述】:
我正在尝试发送 http 请求,如果请求返回的不是 200,则失败:
exec(http("Get some html")
.get("${aggUrl}/somePath")
.check(status.is(200))
.check(regex("websocket=(.*?)&").saveAs("wsLink"))
)
服务器发送401响应:
[HTTP/1.1 401 Unauthorized]{"errors":[{"code":"authentication.failure","message":"Failed to authenticate user details"}]}]
我希望在控制台中出现类似“期望代码 200,但是是 401”的内容
但实际的错误是:
[ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-38' crashed with 'j.u.NoSuchElementException: No attribute named 'wsLink' is defined', forwarding to the next one
[ERROR] i.g.h.a.HttpRequestAction - 'httpRequest-37' failed to execute: No attribute named 'wsLink' is defined
所以我假设“.check(status.is(200))”被忽略了?
那我应该怎么考不及格呢?
提前致谢, 安德烈·伊萨科夫
【问题讨论】:
-
您使用哪个版本的加特林?您是否已升级到最新版本(截至目前为 3.4.0)?
-
你好斯蒂芬!是的,我使用 gatling 3.4.0:
3.4.0 3.1.0 4.4.0 gatling 3.3.1 中的行为相同。 -
其实问题是我看到了regex check的输出,但是没有看到status check的输出。此检查中有一个字段“displayActualValue”,但我不知道如何使用它。编译器总是抱怨。有例子吗?谢谢!
标签: gatling