Search code examples
jmeter

Jmeter: While controller didn't break when conditon is met


I have a sampler within a thread group that need to be executed until it get a status code = 200 If first run is successfull (status code =200) should have only one execution of the sampler else if fail, repeat until status code =200. The sampler execution (status code=200) didn’t stop despite the condition in the while controller. Where am I wrong.

I tried the following: enter image description here

while controller - {__javaScript("${response}"!="200")}

Jsr223 listener -

String ResponseCode = sampleResult.getResponseCode();
vars.put("response",ResponseCode);

Solution

  • Correct __javaScript() function syntax would be:

    ${__javaScript("${response}" != "200",)}
    

    While Controller's documentation suggests using __jexl3() or __groovy() functions so consider migrating.

    • jexl3: ${__jexl3("${response}" != "200",)}
    • groovy: ${__groovy(vars.get('response') != "200",)}