ishan soni
ishan soni

Reputation: 89

how to include parameters in label of Jmeter summary report

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

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

You can get it automatically populated with the help of Beanshell scripting.

Example:

  1. Add Beanshell PostProcessor as a child of HTTP Request
  2. 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());
    
  3. Run your test.

The code fetches URL and all parameters along with their values and updates parent sampler name with these values:

Sampler Name Change Demo

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

Related Questions