I'm finding the way to use the variable sampler
in JSR223 Sampler, JSR223 PreProcessor, JSR223 PostProcessor, and all other JSR223 script.
There are some other variables like vars
, props
, prev
, SampleResult
. I can use them easily.
For example:
vars
: vars.get("VARIABLE_NAME"), vars.put("VARIABLE_NAME","VALUE"), ...props
: props.get, props.put, ...prev
: prev.getTime(), prev.isSuccessful(), prev.getLatency(), ...SampleResult
: SampleResult.getResponseCode(), SampleResult.getResponseMessage(), ...But I don't know how to use variable sampler
. Only thing I can do with this variable is:
sampler.sample()
: It helps to returns the Name of current Sampler
So, could anyome please let me know there is any other way to use this variable?
Thanks in advance!
For JSR223 Sampler sampler
variable stands for JSR223Sampler, see the JavaDoc for all available methods and fields.
When it comes to JSR223 Pre or Post Processor - in that case sampler
variable stands for parent sampler class instance, for instance in case of HTTP Request it will be HTTPSamplerProxy, for JDBC Request - it will be JDBCSampler and so on.
You can check exact class using Groovy expression like:
log.info(sampler.getClass().getName())
You can check How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on pre-defined variables and their usage. It is applicable for Groovy as well.