JMeter While 控制器
我在整个网络上疯狂地寻找解决我的问题的方法,但目前还没有。我的问题是,我必须检查是否在 HTTP 请求中获取特定文本,该文本位于 while 循环中,如果是,那么我应该离开循环并继续线程,或者如果文本不存在则完全停止线程。我的设置如下:
Thread Group
.. While controller
.. HTTP request
.. Response Assertion
Listener
我在 while 控制器中使用了 LAST 并将 HTTP 响应设置为虚假文本,但它不起作用。
I have searched as crazy for the solution to my problem throughout the web, but none exist yet. My problem is that I have to check if I get specific text in HTTP request, which is in a while loop and if I do, then I should leave the loop and continue with the thread or stop the thread completely if text doesn't exist. I have set it up as follows:
Thread Group
.. While controller
.. HTTP request
.. Response Assertion
Listener
I used LAST in the while controller and set HTTP response to false text and it doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
希望以下内容对您有用:
我想您也可以轻松使用 JSR / BSF / BeanShell PostProcessor 附加到您的 HTTP 请求,将 txtFound 属性设置为 TRUE,而不是使用 IF 进行繁琐的构造。
Hope the following one will work for you:
I think you may also easily use JSR / BSF / BeanShell PostProcessor attached to YOUR HTTP Request to set
txtFound
property into TRUE instead of cumbersome construction with IF.试试这个
Try this
http://jmeter.apache.org/usermanual/component_reference.html#While_Controller
WHILE 控制器将一直执行,直到某些内容设置为
FALSE
。通过将条件设置为LAST
,您将不会退出控制器,直到最后一个示例FAILS。如果样本包含您想要的文本,您是否使用断言使样本失败?更简洁的方法可能是使用 beanshell 断言将值设置为 false。
http://jmeter.apache.org/usermanual/component_reference.html#While_Controller
The WHILE controller will execute until something is set to
FALSE
. By setting the condition asLAST
, you won't exit the controller until the last sample FAILS. Are you using an assertion to FAIL the sample if it contains the text you want?A cleaner way might be to a use a beanshell assertion to set a value to false.
为了解决这个问题,我所做的就是创建一个正则表达式提取器并对其进行设置,以便它不可避免地失败并将我的变量设置为 FAIL。然后我将 while 循环设置为 ${__javaScript("${projLoad}" != "SUCCESS")}
在我的条件下,我创建了相同的正则表达式提取器再次失败,但将默认值更改为 < strong>成功
它可能不是最干净的,但效果很好
What I did to get around this issue was create a Regular Expression Extractor and set it up so that it would inevitably fail and set my variable to FAIL. Then I set my while loop to ${__javaScript("${projLoad}" != "SUCCESS")}
Under my conditions I created that same RegEx Extractor to fail again but changed the default value to SUCCESS
It's probably not the cleanest, but works like a charm