JMeter While 控制器 [英] JMeter While Controller
问题描述
我在整个网络上疯狂地寻找解决我的问题的方法,但还没有找到.我的问题是我必须检查是否在 HTTP 请求中获得特定文本,这是在一个 while 循环中,如果我这样做了,那么我应该离开循环并继续线程或如果文本不存在则完全停止线程.我是这样设置的:
线程组.. 而控制器.. HTTP 请求.. 响应断言听众
我在 while 控制器中使用了 LAST 并将 HTTP 响应设置为假文本,但它不起作用.
希望以下方案对您有用:
<前>线程组HTTP 请求//设置找到条件${__setProperty(txtFound,FALSE,)}虽然控制器//在条件中反转值 - 将在 txtFound == FALSE 时执行条件 = ${__BeanShell(!props.get("txtFound")}...[在此处执行您的测试逻辑]...您的 HTTP 请求响应断言//在这里设置你的文本断言//如果找到文本,这将导致 ${JMeterThread.last_sample_ok} = TRUEIF 控制器 --FOUND//如果找到文本,则设置单独的变量或属性 - 例如${txtFound} - 变成 TRUE条件 = ${JMeterThread.last_sample_ok}HTTP 请求//设置找到条件${__setProperty(txtFound,TRUE,)}//这将在下一个 WHILE 循环的条件下反转为 FALSE,WHILE 循环将被退出...我认为您也可以轻松使用 JSR/BSF/BeanShell PostProcessor 附加您的 HTTP 请求 将 txtFound
属性设置为 TRUE,而不是使用 IF 进行繁琐的构造.
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.
Hope the following one will work for you:
Thread Group HTTP Request //set-found-condition ${__setProperty(txtFound,FALSE,)} While Controller // invert value in condition - will be executed while txtFound == FALSE Condition = ${__BeanShell(!props.get("txtFound")} . . . [execute your test logic here] . . . YOUR HTTP Request Response Assertion // set your text assertion here // this will results in ${JMeterThread.last_sample_ok} = TRUE if text found IF Controller --FOUND // if text found set separate variable or property - e.g. ${txtFound} - into TRUE Condition = ${JMeterThread.last_sample_ok} HTTP Request //set-found-condition ${__setProperty(txtFound,TRUE,)} // this will be inverted to FALSE in the next WHILE cycle's condition, WHILE cycle will be exited . . .
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.
这篇关于JMeter While 控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!