What is the correct syntax to supply parameters via the JMeter JSR223 sampler form?

4.1k views Asked by At

I can't seem to find any docs around this, is it simple as this:

//option 1
${something},${something1}
//option 2
123,234,762

Any help would be much appreciated.

2

There are 2 answers

1
Dmitri T On BEST ANSWER

Since JMeter 5.2 the explanation makes more sense, not it looks like:

Parameters passed to script (exposed as 'Parameters' (type String) and 'args' (type String[]))

So if you want to reference the whole line you provide in the "Parameters" section as a single String just use Parameters.

If you want to access individual entries (separated by whitespace) you can use args[0] for the first parameter, args[1] for the second, etc.

Demo:

enter image description here

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It

0
Yuri G On

Consider the script inside the sampler as your public static void main(String[] args).

So, you've got your good 'ol Java args to mess with (I'm not going to elaborate on that, that's basics).

In addition, JMeter puts the raw string as you see it in the box into a pre-set String variable called Parameters - so you can parse it yourself the way you please.

And certainly, JMeter variable referenses/functions are being evaluated if put into parameters list.