How to use CSV Data Set Config in jmeter for multiple user logins

Published On: 9 April 2024.By .
  • General
  • Performance and Security
  • Quality Engineering

In JMeter ,users can use the CSV Data Set Config to read the data from an external source (CSV file) .By using CSV data set config, test plan can be made to have multiple user,all login to the web application instead of just single user.This is useful when the user needs to parameterize with different values for each iteration and then perform activities through these users.

In this blog, We’ll see how we can use CSV Data Set Config element and pass multiple user logins, else we need to pass username and password as hardcoded values, as seen below-

  • Create csv file 

      Firstly, the user needs to create a csv file with the data that the user wants to use.

      Example, if a user wants to test the login functionality, then the user can create a CSV file with two columns -Username and Password and each row contains a set of login credentials.

       

  • Add csv data set config

          Add csv data set config element to the test plan as detailed below in the image.

          Right click on Thread Group -> Add -> Config Element -> CSV Data Set Config.

  • Configure CSV Data Set Config
    • Filename- Upload the created csv file in filename.If the csv file is located on the same folder as .jmx file the add ./ with file name. Example- ./csvtest.csv
    • File Encoding – Select the encoding type for csv file.
    • Variable Name-  Provide a list of variable names corresponding to  CSV file’s columns. A comma should separate each variable name.
    • Delimiter- By default comma (,) is used but user can user /t for tab
    • Allow quoted data- Check this option if data values are enclosed in quotes.
    • Recycle on EOF: If selected, It will loop back to the top of the file when it reaches the end.
    • Stop thread on EOF: If selected, the thread will stop when the end of the file is reached.

  • Use Variable in Sample(http request)

         Now in http request users can use the variables defined in the csv file. 

         Syntax- ${variable name}

         Example – Replace the hard coded username and password in the request parameter with ${username} and {$password}

 

  • Run the Test Plan

          Run the jmeter test plan script, it will automatically pick the username and password from the csv file and execute the test plan.

Related content

That’s all for this blog