Jmeter test script recorder

JMeter, or Apache JMeter, is a free load and stress testing software. It evaluates and quantifies the effectiveness of services, including website performance metrics. It is a helpful tool because it enables us to monitor an application's performance after deployment, giving us knowledge that we can use to enhance our service further.

Moreover, JMeter provides many tools, such as load testing, distributed testing, access logs, etc. One of these which we will discuss in this Answer, is recording tests, specifically test script recorders. A test script recorder lets us add our HTTP request to our storage. Simply put, it is an element that records user actions on the browser. It allows us to store our HTTP requests more efficiently rather than us saving each request individually.

Implementation

There are two ways in which we can create our recorder. Firstly, we can use the recorder template. Templates in JMeter are reusable project scripts. We can use them to generate a test plan with all the necessary components already built into it. Secondly, we can create our recorder from scratch. This Answer will go through both methods to fully understand each concept.

Note: If you have not set up your JMeter, follow this Answer to first set it up and then continue with this answer.

Recorder template

We can use the built-in templates gallery to set up our recorders. There are two recorders available with a slight difference.

  • The first recorder is the "Recording" template. This creates a plan with all the elements needed for starting a recording script.

  • The second recorder is the "Recording with Think Time" template. This creates a similar plan with all the required elements but also has a delay system. This implementation means that it has a built-in random delay to mimic real-world patterns.

Now we will start creating our recorder.

  1. We will first open JMeter and click the templates icon. From there, we will select this Answer's "Recording with Think Time" template. Then we will click "create" to build our test plan.

  2. Now we will go to our "HTTP Request Defaults" and add our website URL in the "Server Name or IP" field. Remember not to add the "https" tag before the link.

HTTP Request Defaults example
HTTP Request Defaults example
  1. We then will go to our "HTTP(S) Test Script Recorder" and click "start". This will create a "Root CA certificate" file in our "bin" folder.

Root CA certificate
Root CA certificate
  1. After getting the certificate, we need to modify our browser settings. For this answer, we will use Firefox Web Browser. If you use another browser, head to the official documentation for help if needed. We will open our Firefox browser and go to settings. From there, search "proxy" and click on the settings tab in "Network Settings". Now, modify the settings as shown below and click ok.

Connection settings
Connection settings
  1. Afterward, we will search for "certificate" and click on the view certificates tab in "Certificates". From there, we will click on import and select our certificate from its location. We will also mark it as trusted for the certificate and click ok to proceed.

JMeter certificate installed
JMeter certificate installed
  1. Everything has been set up, so we will head to JMeter to start our process. We will head to our recorder and press start. Now we can go and log actions on our targetted URL. After we have done everything required, we press stop to close the recorder.

Recorder controls
Recorder controls
  1. After the recording, we can check our logs from the JMeter GUI. For that, we will go to our "Thread Group", then to our "Recording Controller," and then to whatever we named our transaction to see our logs.

Recorded logs
Recorded logs

Recorder from stratch

Another way to create a recorder with specific customizations is to build it from scratch. We will follow the steps below to achieve that. Also, note the difference between using the template model is that it prompts us to enter the URL details in its HTTP request tab, whereas when we build the recorder from scratch, we can skip that step.

  1. We will open our JMeter GUI and load our new "Test Plan". Then we will create a "Thread Group" with our desired arguments. Inside that, we will create a logic controller called "Recording Controller. This will store our logs.

  2. Afterward, we will create a non-test fragment element called "HTTP(S) Test Script Recorder". This will have a start option inside it.

Custom recorder plan
Custom recorder plan
  1. From here on forth, the process is the same as described in the "Recorder Template" from step number 3 onwards. We can follow those steps and reach our required results.

Note: Unless we use a recorder, internet will not work in the browser that we have implemented the proxy settings to. To fix this, remove the proxy settings after the recordings are done.

Conclusion

JMeter's test script recorder tool is powerful for efficient and productive work environments. It helps to easily create test scenarios and custom testing scripts without needing manual entries. Overall, this tool significantly increases testing automation and creates a learning and training platform accessible to its user within a few clicks. Moreover, we can also visit the official JMeter documentation regarding test script recorders to learn more.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved