Reputation: 89
I can successfully create a summary report in jmeter but in the label column i need the full get request along with parameters passed.I am not getting the parameters passed in the url.
Upvotes: 3
Views: 1940
Reputation: 168002
You can get it automatically populated with the help of Beanshell scripting.
Example:
Put the following code into the PostProcessor's "Script" area:
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.testelement.property.JMeterProperty;
HTTPSamplerProxy sampler = (HTTPSamplerProxy) ctx.getCurrentSampler();
StringBuilder builder = new StringBuilder();
builder.append(sampler.getUrl());
Arguments args = sampler.getArguments();
PropertyIterator iter = args.iterator();
while (iter.hasNext()) {
builder.append (iter.next().getStringValue());
}
prev.setSampleLabel(builder.toString());
The code fetches URL and all parameters along with their values and updates parent sampler name with these values:
As you can see HTTP Request
became http://example.com/foo=bar
You can place the PostProcessor at the same level as HTTP Request samplers to avoid copy-pasting it multiple times or use i.e. Beanshell Listener or Beanshell Assertion instead.
See How to use BeanShell: JMeter's favorite built-in component guide for comprehensive information on using scripting in JMeter and to learn what all these things like ctx
and prev
mean.
Upvotes: 5