Welcome to Learn JMeter Series! This series helps you to learn Apache JMeter in a much simpler way with the relevant examples and exercises. This tutorial focuses on Recording on JMeter.
- Introduction to JMeter Elements
- Downloading and Installing JMeter
- Introduction to Apache JMeter
- JMeter Execution Order and Scoping Rules
What is Recording?
To get started with application performance testing, the first step in JMeter is recording your business transactions. Recording the business flow helps to expedite the process of creating test plans. Otherwise, you will be spending more time manually crafting the requests.
Almost any GUI based performance testing tool offers a way to record the application via proxy. But CLI based tools such as k6 adopt a different approach when it comes to recording.
How to get started with recording in JMeter?
In JMeter, by adding a Non-Test element to your test plan, enables you to capture the network traffic. Right click on Test Plan > Add > Non-Test Elements > HTTP(S) Test Script Recorder. This will add the recording capability to JMeter.
To begin recording, understand the business flow and have your input data ready. Preferably clear your cache and cookies from your favorite browser.
Configuring HTTP(S) Test Script Recorder
JMeter records the traffic via proxy. By default, JMeter uses 8888, but it can be configured based on your needs.
Now, open your favorite browser. In this case, I am using Mozilla Firefox, then launch the proxy settings and configure the same proxy as JMeter.
In this series, we are going to use multiple demo websites. To demonstrate the recording capability, we are going to use Bank of Anthos demo app https://bank-of-anthos.xyz/login
Below is the business flow:
- Launch https://bank-of-anthos.xyz/login
- Sign in with the default credentials,
- Click on Deposit Funds
- Enter 10 to the default external account, click on Deposit
- Sign out
Go back to JMeter, add a Thread Group and in HTTP(S) Test Script Recorder, select the Target Controller as Test Plan > Thread Group as shown below.
Then, click on Start. If you get a pop-up, that is fine, click on OK, and then go back to Firefox and launch the https://bank-of-anthos.xyz/login URL.
Once the recording is done, click on the Stop button. In your Thread Group, you can see the recorded elements as shown below.
By default, JMeter records everything. It is your responsibility to remove unwanted requests such as ads, fonts, third party calls etc.
But you can avoid unwanted requests using the network filtering option in JMeter. Click on Requests Filtering in HTTP(S) Test Script Recorder.
Add the below regular expressions under URL Patterns to include.
Then repeat the recording. You will get only the relevant HTTP requests for your test plan.
After the recording is done, it is time to smoke test the recorded elements. Add the View Results Tree listener to the test plan, by right-clicking on Thread Group > Add > Listener > View Results Tree.
You will get the below error when you replay the test plan. That is fine. Let us fix this in a moment.
How to fix the test plan?
Whenever you work on a web application in JMeter, always add Cache Manager, Cookie Manager and DNS Cache Manager from the Config Element category to the test plan. If you replay now, you will not see any errors.
Above test plan cannot be used for load testing yet. There are lot of enhancements to be done. Eventually we will cover everything.
In this blog, you have learned how to capture business transactions in JMeter via proxy and a couple of tips and tricks for successful smoke testing. In our next blog post, we will discuss Data Parameterization in JMeter.
Top comments (0)