Pallavi Sharma
Pallavi Sharma

Reputation: 11

Conditional request in Jmeter

I am using a Bean Shell sampler and a Bean shell preprocessor in my script. I want my Sampler to execute only when I get the value of a parameter defined in the preprocessor. Can anyone help me regarding this?

Upvotes: 1

Views: 2906

Answers (2)

Dmitri T
Dmitri T

Reputation: 168197

You cannot enable or disable samplers in the runtime, basically you have 2 options:

  1. Put your Beanshell Sampler under the If Controller and set If Controller's condition elsewhere
  2. Put your logic in the Beanshell Sampler inside if-then statement like:

    if (someValue != null) {
        //execute some code
    }
    

    So even if Beanshell Sampler will be executed - it will do nothing.

Upvotes: 2

Poorvaja Deshmukh
Poorvaja Deshmukh

Reputation: 129

Add HTTP request inside if controller, so that if value in parameter is same as value defined in preprocessor then only HTTP request will get executed

Upvotes: 1

Related Questions