Posted

Reading Time: 2 minutes

In order to extract data from the response with JMeter you need to:

  • have the CSV file with the credentials in a format similar to the one below
  • have JMeter installed
  • JMeterPlugins-Extras installed – installing the plugins is detailed on the following post
  • JMeterPlugins-ExtrasLibs installed – installing the plugins is described on the following post

Four steps from the CSV file to being able to login and getting the token from the response

1. The CSV file with the credentials

The CSV file that we will use as the source(username and password) for the login process needs to be in a format similar to the following:


user1,password1
user2,password2
user3,password3
user4,password4
user5,password5

2. Create a new thread group and add the CSV Data Set Config as detailed in the images below

using_csv_for credentials1

using_csv_for credentials2

3. Add the JSON Path Extractor that we will use to extract the token from the response as in our case the response is in the JSON format like the following:


{

"data": {

"id": "a964a723ecfb61ba5e54d8cd22420f20",

},

"status": {

"httpStatus": 200,

"success": true

}

}

using_csv_for credentials3

using_csv_for credentials4

The expression that we use in the JSON Path Extractor is $.data.id as this refers to the id field in the data object. You need to adjust this to match your JSON format from the response.

4. Create the call that will access the area in the web application for which the user needs to be logged in and add the HTTP Header Manager that will use the token as a X-CSRF-Token like in the image below

using_csv_for credentials5

using_csv_for credentials6

You are all done, now you can access any part of your web application that needs the user to be logged in using the same process that we used at step 4.

Enjoy.

 





Thanks for reading. I hope you learned something interesting about React!
If you found this article useful, please share it with others. Don’t forget to subscribe to get notified for the upcoming articles.