Jmeter: 当条件满足时,While控制器没有中断。

huangapple go评论71阅读模式
英文:

Jmeter: While controller didn't break when conditon is met

问题

以下是翻译好的部分:

"我有一个在线程组中的采样器,需要执行直到获得状态码等于200。
如果第一次运行成功(状态码=200),应该只执行一次采样器,否则如果失败,重复执行直到状态码=200。尽管在while控制器中设定条件,采样器执行(状态码=200)却没有停止。我错在哪里。

我尝试了以下操作:
查看图片描述

while控制器 -
{__javaScript("${response}"!="200")}

Jsr223监听器 -
String ResponseCode = sampleResult.getResponseCode();
vars.put("response",ResponseCode)"

英文:

I have a sampler within a thread group that need to be executed until it get a status code = 200
If first run is successfull (status code =200) should have only one execution of the sampler else if fail, repeat until status code =200. The sampler execution (status code=200) didn’t stop despite the condition in the while controller. Where am I wrong.

I tried the following:
enter image description here

while controller -
{__javaScript("${response}"!="200")}

Jsr223 listener -

String ResponseCode = sampleResult.getResponseCode();
vars.put("response",ResponseCode);

答案1

得分: 0

Correct __javaScript() function语法应该是:

${__javaScript("${response}" != "200",)}

While Controller的文档建议使用__jexl3()__groovy()函数进行迁移。

  • jexl3: ${__jexl3("${response}" != "200",)}

  • groovy: ${__groovy(vars.get('response') != "200")}

英文:

Correct __javaScript() function syntax would be:

${__javaScript("${response}" != "200",)}

While Controller's documentation suggests using __jexl3() or __groovy() functions so consider migrating.

  • jexl3: ${__jexl3("${response}" != "200",)}
  • groovy: ${__groovy(vars.get('response') != "200",)}

huangapple
  • 本文由 发表于 2023年4月11日 01:38:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979357.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定