Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of if controller for check condition in jmeter

I need to add a check condition for the search result page that, if a search result is found, the script should run further otherwise it should stop on the same step.

This is my Condition in if controller:

${__javaScript("${depdate}"=! null)} 

Here depdate is the regex parameter. If search results are found then its value will be null otherwise it will display content. It's a part of a json string.

I have put all further step in the if controller, but not success. Can anyone help me out of this? What is the reason that this is not working.

What is wrong here with what I am performing?

like image 972
Neha Bansal Avatar asked Oct 12 '15 07:10

Neha Bansal


1 Answers

The reason is that your "${depdate}" will never be null.

  • If ${depdate} variable is set - it will be variable value
  • If ${depdate} variable is not set - it will be default value (which is ${depdate}

Demo:

JavaScript variables

So change your expression to be `${__javaScript(vars.get("depdate") != null)} and everything should start working fine.

See How to Use JMeter's 'IF' Controller and get Pie guide for more information on using IF conditions in your JMeter test.

like image 102
Dmitri T Avatar answered Sep 30 '22 02:09

Dmitri T