英文:
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",)}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论