How to handle Parameterization and Correlation in JMeter?

Abstract

This article is in continuation with my previous article, which shares knowledge of Performance testing using JMeter. This article is for users who want to know the Parameterization and Correlation in JMeter with the aim of handling unique/dynamic values at run time. It is used to run distinct users simultaneously by fetching the data from the CSV file. So, that every time when a script runs with a thread count as 100, it takes new username value from CSV file. This helps in the error handling of unique value during the Sign-up process. Correlation is handling of dynamic value which is returned from the server. Parameterization takes care of user inputted values, while correlation handles data which is returned by the server for any request.

Introduction

Parameterization is used for fetching the values from the CSV file. It is used, when we want to run a script with a different set of users. Through CSV file, we can get a large amount of data which can be used for the script.

For example, If we want to run sign up the script for 100 users, then it might throw an error for unique Email ID and Username, if not met against unique parameters required in the website. To overcome this problem, you need to fetch values from the CSV file by naming the variables as a column header in the CSV file. So parameterization comes into play when we want Test Plan with a different set of users at the same time.

Correlation is used to extract value from a request. For this, we make use of processors which could be pre-processors or post processors. In most of the cases, we make use of post processors. This can be XPath and Regular Expression Extractor. These are used to extract value from response and stores the value in any variable which can be later used in any request for. For example, it can be used for Session ID or cookies value.

 

Configuring “CSV Data Set Config” parameters

It is used to read values from the data file, which can be later used as Test data while executing a JMeter script.

1. Name: To change the name of CSV Data Set Config which will be used in the left side of Tree.

2. Filename: It is the name of the CSV file. If this file exists in bin folder then the only name of the file is required else full path of the file is required.

3. File encoding: It is used to read the file

4. Variable names: It consists of all the variable names, which will be used in the CSV file. These are separated by commas. If this input field is empty then Jmeter will take the 1st row of data as the column name.

5. Delimiter: It is used to separate values in CSV file, a comma is a default delimiter.

6. Allow quoted data?: If it is enabled then it will take value from CSV file which is doubled quoted, by default it is set to false.

7. Recycle on EOF?: It is default set to true which means that once all the set of data is used then it will place the cursor to the beginning of data file for repeating the process.

8. Stop thread on EOF?: Once the whole set of data is used from CSV then JMeter script will stop if it is set as True.

9. Sharing mode: It signifies what all be shared between the threads.

• All threads: If you want to share the file with all threads

• Current thread group: It can be used by each thread group once.

• Current thread: CSV file will be used separately by each thread.

• Identifier: Threads, which are using the same identifier will use the same file

Steps to add elements in Jmeter

Step 1:

a. Adding thread group (Login Script) in Test plan

b. Adding HTTP request Defaults

c. Adding CSV Data Set Config

d. Adding listener as Summary Report to capture the output of JMeter

A JMeter screen will look like this with CSV Data Set Config elements

1stimage_Elements of CSV data Config

Step 2:

Add a text file with extension as .csv in the bin folder of JMeter or you need to copy the absolute path of this file in filename field in the above image.

Textfileplacement

Step 3:

In CSV Data Set Config: Add the same file in Filename field and pass the variable name as username & password

SettingvalueinCSV

Step 4:

When we record a script, then it stores dynamic values which will not be valid when you execute next time. As it expired for next execution or for next run it needs new dynamic value e.g. session id, token key etc. In the below screenshot, I have used regular expression extractor for the session ID. Its value is given in HTTP request in Step 5.  If you are not sure which values are changing at each run, you can compare recorded script Vs new script value. You will observe that there are some values which are changing each time.

RegularExpression

Step 5:

On HTTP Request window, adding value of parameters in Send Parameters With the Request section in value column as shown below in image for userName field: ${userName } , password field: ${password} and osCsid field as ${OSCID}.

HTTP request handler

Step 6:

Now based on the thread added in a jmeter.csv file, for example, lets run the script for 4 threads and set the value in Thread group as 4. Now, run this script with the above HTTP request. It will take parameters from Jmeter.csv file.

For User1:

When the script runs, User 1 details will be sent in a request, next User 2 details will be sent and so on till the script runs for User 4.

Login user 1

Login user 2

About Author:
Author Prakhar Saxena is a Sr. QA Engineer currently working with QSS Technosoft Pvt Ltd. He has completed his Bachelor’s degree in Information Technology.

About QSS:
QSS Technosoft is a leading provider of Quality Assurance and Testing services in India and having a proven track executing enterprise level web and mobile applications for its esteemed customers. QSS has a test center of excellence with a dedicated and experienced team of QA engineers.

Renovate unique Business Processes into Digitally Transformed solutions with QSS Technosoft!!

Do you want to remove manual operations, acting as impediment to your business growth? Realize your ideas into reliable web and mobile software solutions with our professional services. Take first step to launch your project by filling the form.

Moving Arrow point to Contact Form

Let's computerize your business process


or Call Us