venkat sai
venkat sai

Reputation: 475

How to take values of Jmeter variable in coma separated way

I'm hitting a rest Api through http GET request in jmeter. the url is like http://hostName:port/searchParameter=value1,value2,value3

the value1, value2 ... are taken from a file which is like

File.csv value1 value2 value3

this csv file is not really coma seperated values they are in separate lines. Now how to achieve this

Upvotes: 1

Views: 569

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

JMeter doesn't provide a suitable test element so you will have to go for __groovy() function and some custom scripting.

I can think of using File.readLines() function to read the contents of your file into memory followed by join() function to convert the array into a comma-separated string.

The final syntax would be:

${__groovy(new File('File.csv').readLines().join('\,'),)}

Demo:

enter image description here

Check out Apache JMeter Functions - An Introduction article to get familiarized with JMeter Functions concept.

Upvotes: 1

Related Questions