controller - JMeter Controller

标签 controller while-loop jmeter

我已经疯狂地在整个网络上搜索解决我的问题的方法,但目前还没有。我的问题是我必须检查是否在 HTTP 请求中获得特定文本,该请求在一个 while 循环中,如果我这样做了,那么我应该离开循环并继续线程,或者如果文本不存在则完全停止线程.我设置如下:

Thread Group
.. While controller
   .. HTTP request
      .. Response Assertion
Listener

我在 while Controller 中使用了 LAST,并将 HTTP 响应设置为假文本,但它不起作用。

最佳答案

希望以下对您有用:

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
    . . .

我想您也可以轻松使用 JSR / BSF / BeanShell PostProcessor附加到 YOUR HTTP Request 以将 txtFound 属性设置为 TRUE,而不是使用 IF 进行繁琐的构造。

关于controller - JMeter Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7886132/

相关文章:

ajax - ajax发布不捕获错误,总是捕获成功

routes - 有没有办法在上述请求 DTO 之外的其他地方声明路由?

php - while 循环将 1 添加到文件名(如果它已经存在)在 PHP 中不起作用

将文件从 AWS EC2 上传到 S3 的 Shell 脚本

jmeter - 如何在 JMeter 中的两个 JSR223 (groovy) 采样器之间传递非字符串值?

JMeter - 某些函数无法在 Function Helper 中执行

ruby-on-rails - #<WelcomeController :0x00000006ab2df8> 的未定义方法 `layout'

javascript - sails.js 中 Controller 与 typescript (或不 typescript )之间的继承

javascript - 即使网站未在使用,也会在未来的日期/时间执行功能?

php - 如何在数组中创建一个新字段?