JMeter is an open source performance tool is widely used for performance testing variety of applications. This will be a series of posts on how to use JMeter as a performance testing tool. This article will explain how to create a recording of Web Application traffic which you can then captured and be used for playback using JMeter.
When JMeter is launched the default items loaded are Test Plan and Work bench. To start with recording using JMeter, A thread group has to be added to the Test Plan
- Navigate to Test Plan –> Right Click –> Add –> Threads (users) –> Thread Group
Add Http Requests defaults to the thread group
2. Navigate to thread group –> Right Click –> Config element –> Http Requests default
3. Configure Http Requests default – Enter the URL that the script has to be generated for in the field Server Name or IP
Add a Http Proxy server to the Work Bench
4. Navigate to Work bench –> right click –> Non Test elements –> Http Proxy server
5. Configure the Http Proxy Server with below values
Port: 8080 (default value)
Target Controller: Test Plan > Thread Group
Grouping: Put each group in a new Transaction controller
Please refer to the screenshot
Click on Add button under the section “URL Patterns to Include” and enter “.*” (without double quotes) representing everything has to be recorded
Click on Add button under the section “URL patterns to exclude” and enter.*\.jpg, .*\.png, .*\.js, .*\.css one at a time as show in the below screenshot. The syntax has to be followed exactly otherwise the scripts may not be recorded in JMeter.
6. Now configure your favorite browser to send the requests on the port 8080. In case of Internet explorer the steps are as below:
Launch IE –> Navigate to tools –> Internet options –> Connections –> LAN Settings –> Check the field “Use a proxy server for your LAN and enter the details as Address: localhost and port 8080. Screenshot attached for reference
Now everything is set to start recording the user actions in JMeter
Navigate to Http Proxy Server and click on Start button. JMeter starts sniffing the network traffic on the port 8080. Unlike commercial tools the browser is not launched automatically. The browser has to be launched and the user activities are to be performed.
After each user action ensure that the script is getting recorded and change the name of the transaction controller as shown in the below screenshot
Once all the user actions navigated and they are recorded into the JMeter script, click on the stop button under the Http Proxy Server.
The script recording is done in JMeter.
This may seem like a lengthy process. TIP:: There is a partially open source tool (because of its license terms) called Badboy where the user actions can be recorded (similar to any commercial performance testing tool) and finally the script can be exported as a JMX file, this can be directly imported into JMeter. Sounds easy? This method has to be followed if the web application uses the secured http protocol i.e. https protocol.
Happy Script Recording in JMeter.