Arun Lal
Arun Lal

Reputation: 5

Convert Jmeter __V function variable into groovy vars.get

I have a JMeter variable like this:

${__V(myVar${counter})} 

How to get the value of this variable inside JSR223 sampler by using vars.get() ?

Upvotes: 0

Views: 626

Answers (2)

Dmitri T
Dmitri T

Reputation: 168002

There are 2 options:

  1. Use "Parameters" section of the JSR223 Sampler (as the documentation suggests)

    enter image description here

  2. Use GString Template feature like:

    vars.get("myVar${counter}")
    

    where vars is the shorthand for JMeterVariables class instance, see the JavaDoc for all available functions and Top 8 JMeter Java Classes You Should Be Using with Groovy article to learn more about JMeter API shorthands available for JSR223 Test Elements

Upvotes: 0

Ori Marko
Ori Marko

Reputation: 58774

Use nested get:

 vars.get("myVar" + vars.get("counter" ));

Upvotes: 0

Related Questions