且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JMeter-如何在IF Controller中使用多个条件?

更新时间:2022-05-27 22:27:17

是的,假设您当前的条件 SMTP采样器将被执行:

Yes you can, assuming your current condition SMTP Sampler will be executed:

  • 如果${responsecode}变量是404

OR

如果${responsecode}变量是500 AND ${responseMessage}变量是Not Found

If ${responsecode} variable is 500 AND ${responseMessage} variable is Not Found

我怀疑给出响应代码500 ,很可能您会在那得到一个Internal Server Error,所以也许您应该将条件修改为:

I doubt that you will get Not Found message given Response Code 500, most likely you will get an Internal Server Error there so maybe you should amend your condition to look like:

"${responsecode}" == "500" || ("${responsecode}" == "404" && "${responseMessage}" == "Not Found")

如果Controller的行为不正常,请首先检查 jmeter.log 文件中是否有与JavaScript相关的错误,它将为您提供一些有关设置错误的线索.您还可以使用 __javaScript()函数

In case when If Controller doesn't behave as expected first of all check jmeter.log file for any JavaScript-related errors, it will give you some clue regarding what's wrong with your setup. You can also use __javaScript() function and View Results Tree listener combination to visualize the result of your If Controller condition:

请参见如何使用JMeter的'IF 控制器"一文,详细介绍了通过If Controller有条件运行采样器的情况.

See How to Use JMeter's 'IF' Controller article for more details on conditionally running samplers via If Controller.