How to change User Agent string in JMeter?

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.

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.

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.

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.

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 the Author

1 thought on “How to change User Agent string in JMeter?”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Hamster - Launch JMeter Recent Test Plans SwiftlyDownload for free
+
Share via
Copy link