I'm using JMeter 5.0 and i'm trying to loop over a database resultset.
For the sake of simplicity here we'll just use "3" instead of vars.getObject("resultSet").size() which is my resultset's size)
I'm trying to use the WHILE component's own index to make it stop
(Please do not show me how to use the counter component since I could make it work myself given all the help i've found regarding JMeter's WHILE uses a counter , but it is counter-intuitive to me (no pun intended), just like incrementing "i" in any other language :
`
for(int i = 0;i < 10;)
{
// do stuff
i++;
}
`
I the syntaxes i found and tried (my while component is named LOOP):
${__jm__LOOP__idx} < 3 : Returns no error but does not stop
${__javaScript("${__jm__LOOP__idx}" < 3 )} : Returns no error but does not loop either.
${__javaScript(${__jm__LOOP__idx} < 3)} :
Works and stops looping after 3 but returns this error :
javax.script.ScriptException: <eval>:1:1 Expected ; but found {
${__jm__LOOP__idx} < 3
^ in <eval> at line number 1 at column number 1
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470) ~[nashorn.jar:?]
Thank you in advance for any help you may provide, and for your time.
Provided your While Controller is named LOOP, use this as condition , it uses __jexl3 function:
${__jexl3(vars.get("__jm__LOOP__idx") == null || vars.get("__jm__LOOP__idx") < 3,)}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With