parameterization and correlation in JMeter

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, every time when a script runs with a thread count of 100, it takes a new username value from the CSV file. This helps in the error handling of unique values during the Sign-up process. Correlation is the handling of dynamic value which is returned from the server. Parameterization takes care of user-inputted values, while correlation handles data that 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 files, we can get a large amount of data that can be used for the script.

For example, If we want to run sign up a script for 100 users, then it might throw an error for a unique Email ID and Username, if not met against the 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 a 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 cases, we make use of post-processors. This can be XPath and Regular Expression Extractor. These are used to extract value from the response and store the value in any variable which can be later used in any request. 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 the bin folder then the only name of the file is required else the full path of the file is required.

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

4. Variable names: These 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 a 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 the extension as .csv in the bin folder of JMeter or you need to copy the absolute path of this file in the 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 it next time. As it expired for the next execution or for the next run it needs a new dynamic value e.g. session id, token key, etc. In the below screenshot, I have used a regular expression extractor for the session ID. Its value is given in the HTTP request in Step 5.  If you are not sure which values are changing at each run, you can compare the recorded script Vs the new script value. You will observe that there are some values that are changing each time.

RegularExpression

Step 5:

On HTTP Request window, add the value of parameters in Send Parameters With the Request section in the value column as shown below in the 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

Book your free consultation with us

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 QAengineers.

Tags: , , ,

Hire certified

Developers

  • Avg. 6+ Years of Experience.
  • Dedicated Resource on Demand.
  • NDA Protected Terms.
  • Start/Interview within 24 Hours.
  • Flexible Engagement Models.
  • Best code practices.
Start Now!
E-Book

eBook

6 Most Important Factors for a Successful Mobile App!

Every precaution that you take in the development process will help you to be effective in building products that will help you grow and reach your goals. Consider these 6 factors before heading for mobile app development.

Subscribe to our newsletter and stay updated

Loading