JMeter-如何在IF Controller中使用多个条件? [英] JMeter - How can I use multiple conditions in IF Controller?

查看:2946
本文介绍了JMeter-如何在IF Controller中使用多个条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

在If Controller->条件(默认Javascript)中,我提供以下内容 "$ {responsecode}" =="404" || "$ {responsecode}" =="500"&& "$ {responseMessage}" ==未找到"

In If Controller -> Condition (Default Javascript) I am providing following "${responsecode}" == "404" || "${responsecode}" == "500" && "${responseMessage}" == "Not Found"

推荐答案

是的,假设您当前的条件 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.

这篇关于JMeter-如何在IF Controller中使用多个条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆