Read values from CSV using JMeter

Hola Testers!

What would you do if you have to test dynamic values for a specific test field. For example you have to test login for N number of users. How do you use Jmeter for that? Today I’m going to tell how to deal with that kind of situation.

For above kind of a scenario, you can use an external data source to keep your test data. Jmeter support with CSV files greatly. SO we’ll use a CSV file to demonstrate this. Let’s take a scenario. I’m taking login scenario for alfresco. So, in order to log, you need username and password. That are our test data. Let’s create test data in CSV.

CSV Test Data
In our scenario we need to store username and password in CSV. I already created 4users with admin in alfresco. Now we’ll create a CSV file.
You can create a CSV in two ways
With heading
Without heading

You can use either with heading or without heading. Then save this file as a .csv

Add CSV Configuration file to Jmeter projet
Right click on the Test Plan > Add > Config Element > CSV Data Set Config
Screen Shot 2016-04-04 at 2.01.53 PM.png

Configuration CSV Config Element
Open “CSV Data Set Config”
Filename: CSV doc path with csv filename
If you write csv with heading, this is enough
Screen Shot 2016-04-04 at 2.09.05 PM.png

If you write csv without heading, then you need to add “Variable Names” for the values with separate by comma(,)
Screen Shot 2016-04-04 at 2.10.54 PM.png

Add parameters to the HTTP request
As we set our variables as “username” and “password”, we need to replace the HTTP request’s send parameters like ${username} and ${password}
Screen Shot 2016-04-04 at 2.17.27 PM.png

Now save the project and run again 🙂

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s