Pooja Patil
Pooja Patil

Reputation: 49

How to use variables within JSR223 preprocessors in jmeter

I am using two JSR223 preprocessors,in which I want to use variable from one preprocessor into another preprocessor.

how can I use this in Jmeter??

Please assist me with an example.

Upvotes: 2

Views: 8657

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

  1. In the first PreProcessor store some value into a foo JMeter Variable using vars shorthand for JMeterVariables class instance like:

    vars.put('foo', 'some value')
    
  2. In the second PreProcessor you can read the value using the same vars shorthand like:

    String myString = vars.get('foo') 
    

See Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on this vars shorthand and other JMeter API shortcuts available for the JSR223 Test Elements

The variable can be seen using Debug Sampler and View Results Tree listener combination.

Upvotes: 4

Related Questions