December 16, 2012

How to change User Agent string in JMeter?

How to change user agent string in apache jmeter - QAInsights

In this blog post, we will see about how to change user agent string in Apache Jmeter. Before you read on further, I request check my last post about role of user agent in software testing and about Jmeter.

Below is the recorded Jmeter script which has one Thread Group and Loop Controller. Loop Controller has three HTTP requests. Each request has HTTP Header Manager.

How to change user agent string in apache jmeter - QAInsights

HTTP Header Manager consists the headers which will be sent along with the request to the server. It usually contains following information such as Accept Language, Accept, User Agent, and Accept Encoding.

During recording, HTTP header manager stored following user agent string Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0. To change the user agent, first disable all HTTP Header Manager in your test plan.

Then, right click on the Thread Group > Add > Config Element > HTTP Header Manager. By adding HTTP Header Manager to your Thread Group, it over writes the header info for all the requests/samplers under that thread group.

Add Config Element ot JMeter Test Plan - QAInsights

Click on HTTP Header Manager, and then click on Add in the HTTP Header Manager element. New row gets added, double click on first cell i.e. Name and enter User-agent and enter the user agent string “Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25” for Safari 6.0.

Add HTTP Header Manager Element to JMeter Test Plan - QAInsights

Click on Save, it prompts you to save. Enter a valid name and save it. Add a View Results Tree, and execute the script.

In the View Results Tree, click on the first request, and then click on Request, you could see the new User-agent string which sent along each requests.

User Agent in Request Header in JMeter Result Tree - QAInsights

By sending different user agents, it will help to validate the performance of web applications in multiple devices and broswers.

Happy Testing!

Subscribe to our QAInsights YouTube Channel. If you are enjoying our work, please do subscribe our free weekly newsletter or Google feeds.

About NaveenKumar Namachivayam

Hi there! is a passionate and experienced Performance Test Analyst based in Chicago, USA with skill sets in Manual Testing, Test Automation, Performance Testing, and Test Estimation. He loves to learn and experiment new trends and models in Software Testing. Please stop by at his personal blogs: Excel Blog, DealsBrook,, and Affiliate Insights blog and Software Testing Memes.

One Comment on “How to change User Agent string in JMeter?

January 9, 2017 at 12:26 pm

What should i write for IE10 on windows7 professional


Leave a Reply

Your email address will not be published. Required fields are marked *