Multiple user login using Jmeter- Parameterization


Parameterization is a process of passing data values from external source to our test plan so that the test can be carried out with different sets of data and not just limited to the single data set. In Jmeter we can make use of "CSV Data Set Config" (one of the config element in Jmeter) to pass data to the test plan. By doing so, the load test plan can be made to have multiple users, all login to the web application and perform activities, instead of just having a single user performing multiple iterations as set in the thread group count.

In the previous section, we've seen how we can make use of Regular expressions and "Regular expression extractor" post processor to handle the dynamic response generating during the login. Now we want to perform the login with multiple users and then perform activities through these users.

In this tutorial, we'll see how we can make use of the 'CSV Data Set Config' element and pass multiple user logins as parameters. Also, we'll make use of 'Debug sampler' to verify whether our Jmeter test plan is able to login with multiple users or not. So in our earlier test plan, we had passed the username and password as hardcoded value, as seen below.



But we want to login with 4 different users. To do so, we'll parameterize our load test plan as shown below:

Parameterize login activity in Jmeter


1. Create a CSV file and provide valid username and password as shown below in the test data CSV file:




2. Now add a 'CSV Data Set Config' at the thread group level, and pass the test data file (CSV) in this data set config element.

csv data set config


3. Browse and upload the CSV test data file in the "Filename" field. Select the "File encoding" as "UTF-8". Let other fields remain at their default values.

csv data set config


4. Now replace the hardcoded username and password values in the request parameters with variables as ${username} ${password}




5. To validate whether the login with multiple users is successful or not, add a debug sampler under the request samplers. This debug sampler will show us the response data at run time, through which we can validate whether the multiple user's logins are successful or not by analyzing the username and password value in the response data.


6. Lastly, update the thread count from 1 to 4 under the thread group.


7. Run this test plan, and analyze the tree view result. There would be 4 iterations with 4 different users. You can see 4 different debug samplers are there in the tree view result. Each debug sampler has a different username and password value same as we passed in the test data CSV file. Also, the '_csrf' value is different for every login which we handled through the Regular expression extractor.

Below debug sampler showing us the login performed with user jj1

debug sampler


Below debug sampler showing us the login performed with user jj3

debug sampler


Below debug sampler showing us the login performed with user jj2

debug sampler


Below debug sampler showing us the login performed with user jj4

debug sampler

Also, we can see that the "_csrf" value is unique for the respective users.