Sourabh Chapali
Sourabh Chapali

Reputation: 391

Jmeter , How to pass comma seperated multiple values in jmeter

Sometimes for same param I have to send multiple values ,Please find the details of the request below

GET Request with parameters

http://samplelink.com?name=john,mary,souds
http://samplelink.com?name=ram
http://samplelink.com?name=john,mary,souds,lakhan,jaby

How do I use this in jmeter at runtime to pick the values ? and what should be the file content of csv config.

Upvotes: 1

Views: 2232

Answers (2)

Dmitri T
Dmitri T

Reputation: 168122

The easiest is going for __StringFromFile() function.

  1. For example you have file names.txt in JMeter's "bin" folder with the following content in it:

    john,mary,souds
    ram
    john,mary,souds,lakhan,jaby
    
  2. Once done you can just use __StringFromFile() function in the HTTP Request sampler "Path" field like:

    http://samplelink.com?name=${__StringFromFile(names.txt)}
    

Demo:

enter image description here

More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

Upvotes: 1

Ori Marko
Ori Marko

Reputation: 58812

You can still use CSV Data Set Config, either by using double quotes:

Meter allows values to be quoted; this allows the value to contain a delimiter. If "allow quoted data" is enabled, a value may be enclosed in double-quotes. These are removed. To include double-quotes within a quoted field, use two double-quotes. For example:

1,"2,3","4""5"

Or use different delimiter as @ to get values from CSV file:

Delimiter Delimiter to be used to split the records in the file. If there are fewer values on the line than there are variables the remaining variables are not updated - so they will retain their previous value

For example file would be:

 1@2,3@4,5

Upvotes: 1

Related Questions