I have an Config Element in JMeter, Especially User Defined Variables.
I have the variable "user" with the value "Justin", How can I use this variable in the groovy code (of an JSR223 Assertion)?
There are several of getting it:
Parameters
which contains the full string passed in the "Parameters" sectionargs[0]
(if you pass more than one variable separated by spaces you will be able to refer 2nd variable as args[1]
, 3rd as args[2]
, etc.vars.get('user')
where vars
stands for JMeterVariables class instance vars['user']
- basically the same as point 3 but uses some Groovy Syntax Sugar ctx.getVariables().get('user')
- where ctx
stands for JMeterContextService class instance just in case (in some test elements vars
shorthand is not available) Demo:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With