shinjidev
shinjidev

Reputation: 397

JMeter: While condition with property value

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

Upvotes: 0

Views: 942

Answers (2)

Dmitri T
Dmitri T

Reputation: 168072

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

Upvotes: 1

Pankaj
Pankaj

Reputation: 77

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

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

Upvotes: 1

Related Questions