Record and Play Load Testing in 5 Steps
Record and Play Load Testing in 5 Steps
Learn more about record and playback load test scenarios in this post!
Join the DZone community and get the full member experience.Join For Free
While Apache JMeter allows you to create a load test from scratch, it also gives you the opportunity to record and playback load test scenarios for your web or mobile applications. Recording performance test scenarios are very useful when it comes to web or mobile testing. Websites and mobile applications make many requests varying from the initial server to third-party applications, like analytics sites, etc. Therefore implementing those requests from scratch may not be the best idea. In those cases, we recommend you to use the recording module of JMeter.
JMeter has a special module for that purpose. It’s called HTTP Test Script Recorder. This module works as a proxy on the host and port that you provide and listen to the HTTP requests. Then, it creates HTTP Sampler for recorded requests.
How to Configure HTTP Test Script Recorder
Go to Non-Test Elements and select the module.
In that screen, you will see many configuration elements. Some of them are mandatory, some are not.
- Port is mandatory. This port number will also be used in your browser. So, select an empty port. JMeter proxy is not ready with basic configuration.
Others configuration items are optional. But there is one item that you should configure from our experience. That’s the Grouping section. During script recording, we’ll simulate an end-to-end test. Therefore, many pages, jpeg, or CSS files will be captured. But we need to distinguish which request is made on which page or application module so that during execution, JMeter will create readable reports.
There are five choices:
- 1) Do not group sampler: Don’t use this one for your sake. Every request will be listed on the same label and it’s not easy to distinguish which request belongs to which action you made during test recording.
- 2) Add a Separator Between Each Group: A basic separator will be added between every action you made during recording.
- 3) Put Each group in a new Controller: This will also record your test scenario according to your actions and create a Controller for each action you made.
- 4) Put each group in a New Transaction Controller: That’s basically the same as the third option but there’s a slight difference. Transaction Controller lets you aggregate the results under one label. The controller doesn’t.
- 5) Store the 1st Sampler of each group only: This one will save only the first request of every action you made. That might not be the best solution as we mostly want to capture all requests.
There is another config that you might want to do. That’s “Which file to be excluded during recording?”
Add file extensions that you don’t want to capture to URL Patterns to Exclude.
Regular expression pattern is .*\.extensionName.*
The reason we do this is that those files are mostly dynamic and they are likely to change in near future. This is about a newspaper website and images are changing every minute. So, there’s no need to capture those things. We are able to call dynamic content by making a small configuration.
This configuration can be done by adding an HTTP Request Defaults to your test plan.
Add an HTTP Request Default, then go to the Advanced tab. Select Retrieve All Embedded Resources
Now, JMeter will always request the most updated embedded content for the pages that you visit. Think about creating a Random Product when clicking on an e-commerce web page. Every time we hit another product, JMeter will ask about the resource for those products when this is configured.
Configure your browser’s proxy settings to JMeter’s setting that you made in step 1. Then, hit the Start button in Test Script Recorder.
Now, you can capture any request.
Happy load testing!
Published at DZone with permission of Canberk Akduygu . See the original article here.
Opinions expressed by DZone contributors are their own.