0
votes

i have been searching, how can i pass two values in one parameter from a csv file, for example. i need to put the names john and mary in the parameter "name"

so the link should look like this --- http://samplelink.com?name=john&name=mary BUT some scenario have just one name,, so the link would be --- http://samplelink.com?name=john

Using jmeter for API test

Thanks !

1

1 Answers

2
votes
  1. Given you have CSV file which looks like:

    john,mary
    joe
    ann,jim
    
  2. Add CSV Data Set Config to your Test Plan and configure it like:

    JMeter CSV Data Set Config

  3. Add JSR223 PreProcesssor as a child of your HTTP Request sampler and put the following code into "Script" area:

    def name = vars.get('name')
    name.split(',').each { currentName-> 
        sampler.addArgument('name', currentName)
    }
    
  4. That's it, JSR223 PreProcessor will obtain the current value of ${name} variable, split it by comma and add a request parameter for each found value.

More information: A Quick Guide to JMeter PreProcessors