JMeter - 如何在 IF 控制器中使用多个条件? [英] JMeter - How can I use multiple conditions in IF Controller?
问题描述
这是我的代码:
在 If Controller -> 条件(默认 Javascript)中,我提供以下内容"${responsecode}" == "404" ||"${responsecode}" == "500" &&${responseMessage}" == 未找到"
是的,您可以,假设您当前的条件 SMTP Sampler 将被执行:
如果
${responsecode}
变量是404
OR
如果
${responsecode}
变量是500
AND${responseMessage}
变量是 <代码>未找到
我怀疑您是否会收到
参见 如何使用 JMeter 的 'IF' Controller 文章,了解有关通过 If Controller 有条件地运行采样器的更多详细信息.
Here is my code:
In If Controller -> Condition (Default Javascript) I am providing following "${responsecode}" == "404" || "${responsecode}" == "500" && "${responseMessage}" == "Not Found"
Yes you can, assuming your current condition SMTP Sampler will be executed:
If
${responsecode}
variable is404
OR
If
${responsecode}
variable is500
AND${responseMessage}
variable isNot Found
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")
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:
See How to Use JMeter's 'IF' Controller article for more details on conditionally running samplers via If Controller.
这篇关于JMeter - 如何在 IF 控制器中使用多个条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!