0
votes

I want to control my sampler based on responseCode and needs to run n number of time defined in counter.
I used while controller and used condition as described below but it's not working as expected.
my condition in jmeter while controller :

${((${ctx.getPreviousResult().getResponseCode()} == "200" && ${counter} < 5),)}

But it's not working as expected, could you please someone please help me on this.

2
Response code is an int, try == 200 (without double quotes)gtosto

2 Answers

0
votes

response code is an int try to use

(${ctx.getPreviousResult().getResponseCode() == 200} && ${counter} < 5)

that is without the double quotes

0
votes

Your condition is malformed, you need to use i.e. __jexl3() or __groovy() function which evaluation result returns true. It can also be a JMeter Variable having value of true which can be set to false somewhere else. But your expression is interpreted "as is" and not being evaluated.

Suggested amendment:

${__groovy(!ctx.getPreviousResult().getResponseCode().equals('200') && (vars.get('counter') as int) < 5,)}

More information: Using the While Controller in JMeter