In jmeter, can we use few parameters with in what we declared in the HTTP request parameter section

139 views Asked by At

In my case i have created one HTTP Request with all the possible parameter as below - enter image description here

My .csv file is looking as below - enter image description here

For some test case i need to send details in one or two parameter only, not for all. Now how can i do that in the same HTTP request without creating a new one?

1

There are 1 answers

1
Dmitri T On BEST ANSWER

Theoretically you can just send empty parameter values, just make sure that you have a blank value in the CSV file, i.e.:

param1,param2
foo,bar
baz,
,qux

enter image description here

Alternatively if you want to completely remove the parameters with empty values from the request you can add a JSR223 PreProcessor as a child of the HTTP Request sampler and put the following code into "Script" area:

def newData = new org.apache.jmeter.config.Arguments()

0.upto(sampler.getArguments().size() - 1, { idx ->
    def arg = sampler.getArguments().getArgument(idx)
    if (!arg.getValue().equals('')) {
        newData.addArgument(arg)
    }
})

sampler.setArguments(newData)

This way JMeter will remove the parameters which don't have their respective values from the request:

enter image description here

In the above example sampler stands for HTTPSamplerProxy, see the JavaDoc for all available functions decriptions

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