0
votes

I currently have a problem with While Controller in JMeter I have a While Controller with many steps inside it, the final step has a BeanShell Assertion with something like this

${__setProperty(sessionUID_global,${sessionUID})};

I'm trying to put a condition for While Controller like this:

${__javaScript(vars.get("sessionUID_global") == null)}

But, It's not working Could anyone help me to stop the while controller with a condition when sessionUID_global has a value?

Thank you

2

2 Answers

1
votes

You need to change this:

${__javaScript(vars.get("sessionUID_global") == null)}

to this:

${__javaScript(props.get("sessionUID_global") == null)}

Going forward:

  1. Consider switching from the Beanshell Assertion to JSR223 Assertion with the following code:

    props.put('sessionUID_global', vars.get('sessionUID'))
    
  2. Consider migrating While Controller's condition to __groovy() function like:

    ${__groovy(props.get("sessionUID_global") == null)}
    

As starting from JMeter 3.1 you should be using JSR223 Test Elements and __groovy() function for any form of scripting

1
votes

JMeter variables are never null. To check the condition, you can use for example:

${__javaScript(vars.get("sessionUID_global")>0)}