jmeter使用if控制器,JMeter - 如何在IF控制器中使用多个条件?

Here is my code:

In If Controller -> Condition (Default Javascript) I am providing following

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

cae0ebb4e147d17e9a34d4c2c5c3aa31.png

解决方案

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

If ${responsecode} variable is 404

OR

If ${responsecode} variable is 500 AND ${responseMessage} variable is Not 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:

4df0c15da3d8fb1fa3f0a53fbe003429.png

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值