If you need to test a web-site, the first thing you should do is a Login operation. JMeter has an element that allows you to read different parameters from a text file. It is the “CSV Data Set Config” element which is used to read lines from a file, and split them into variables.

First I will create a test-plan. It contains one Thread Group. A Thread group consists of “HTTP Request Defaults”, “CSV Data Set Config” and “HTTP Request”. Also, I will add “Aggregate Report” and “View Results Tree”. See Figure 1.

CSV Data Set Config
Figure 1

I guess that if you read this article, there is no sense in explaining how to use “HTTP Request Defaults”, “HTTP Request”. Also, I hope you already know that “Aggregate Report” and “View Results Tree” are used for gathering results. Look at the Figure 2.

CSV Data Set Config fields
Figure 2

You’ll need to fill in at least 3 values on this screen:

  • Filename: if your file is in the /bin directory, this can be just the filename. If it’s somewhere else, use the full path to the file.
  • Variable names: this is the equivalent to a “column name” in a spreadsheet.
  • Delimiter: comma is the default delimiter, but if your file uses tabs, this is the place to say so.

The other fields are optional but they may be useful to you. Read all about them on the JMeter CSV Data Set Config user manual.

I have 4 variables for passing to Login request. They are “user”,”passwrd”,”cookielength”,”cookieneverexp”. And, look at the Figure 3 to see what I have in csv_data.txt.

How to fill csv_data.txt
Figure 3

Let’s switch to Login request, Figure 4.

HTTP Post request
Figure 4

You see the table with variables. There are 4 variables, the same quantity as in 'CSV Data Set Config', but the 4th variable is invisible due to JMeter issue. As you can notice, the value field has the same name as variable in 'csv data set'. Construction ${….} means that is variable, but not absolute value.

Now, if I run the test-plan, JMeter will parse 'csv_data.txt' and change ${passwd}, ${user}, etc., with their values. Results are displayed on Figure 5.

HTTP Post request results
Figure 5

It is worth mentioning that every 'CSV Data Set Config' is visible to all Thread Groups by default. If you need to use separate 'CSV Data Set Config' element for every Thread, you have to create a number of data files that you need, and in 'CSV Data Set Config' element set it from “Sharing mode” to “Current Thread”



Want to learn more? You'll want to view our on-demand recording, How to Create Advanced Load Testing Scenarios with JMeter

Have more questions? Submit a request


  • 0
    Lyle Henkeman

    Thanks for this article, excuse the ignorant question. No one is saying how to actually use the CSV in correlation with Blazemeter. I understand the concept of using it with Jmeter, either you don't put the entire location of the .txt file or you do.. How do I this in Blazemeter?

Please sign in to leave a comment.