Rohan RM
Rohan RM

Reputation: 157

How to read excel file and use it as a variable for different body in jmeter

I have a url. I have created 50 threads in jmeter. I want to post 50 different bodies to 50 different threads. The parameter that should be unique in each body is stored in an excel file, in 50 rows. For each body i want to use these 50 variables in excel sheet , one by one row wise. How can this be done?

Upvotes: 1

Views: 3508

Answers (1)

Dmitri T
Dmitri T

Reputation: 168072

If your file is realy excel (i.e. xls or xlsx) you can read them using i.e. JSR223 Sampler and Apache POI library like described in the How to Implement Data Driven Testing in your JMeter Test guide.

You should get variables like:

var_1=foo
var_2=bar
var_3=baz

There are 2 ways of iterating the variables:

  1. Using ForEach Controller

    enter image description here

    enter image description here

  2. Using __V() and __threadNum() functions combination like ${__V(var_${__threadNum})}

    enter image description here


However if you can control the Excel file it will be much easier to save it as .csv and use CSV Data Set Config

Upvotes: 3

Related Questions