Apache JMeter Test Script Recorder: Part 1

Apache JMeter Test Script Recorder: Part 1

2020 / 1 / 27

Jmeter, Test Script Recorder, JMeter Proxy

Apache JMeter Test Script Recorder: Part 1

After using JMeter, you guys must be wondering does there exist any way to record browser interactions with JMeter? Well, the answer is YES!!! You can definitely record the interactions but you need to do some preliminary setup to get things done. JMeter's HTTP(s) Test Script Recorder is designed to record test scenarios.

In this blog post, our aim will be to get your system i.e. your JMeter ready for recording the browser interactions. For that you need to do the following:

  1. You need to understand what is a Proxy and How the recorder exactly works.
  2. How to intercept and record HTTP requests.

In the next blog post, we will see how to intercept and record HTTPS requests.

Prerequisites:

  1. You must have JMeter successfully installed in your system. You can refer to the article Getting Started with JMeter: Part 1: Installation and Executing JMeter in Different Modes to get a step by step guide on How to install JMeter.
  2. You should have an idea of how to launch and use JMeter.

How Proxy Works???

All of you must be aware of How a Proxy actually works.Proxy is nothing but a component that is placed between you and a remote server. What Proxy do is to pass your queries to the remote server and at the same time, it transmits the result sent by the remote server to you. This means if we use JMeter as a Proxy, it can record all of your browser interactions with a server whether HTTP or HTTPS.

You are right, How to use JMeter as a Proxy? The answer is very simple, JMeter Test Script Recorder is designed in a way to provide this functionality of Proxy.

Configure Browser to use JMeter Proxy:

Firefox Setup:

1. Open Firefox.
2. Open Preferences. There are 3 ways to open Preferences.

  1. Go to Edit->Preferences
  2. Or Go to Tools->Preferences
  3. Or you can type about:preferences#advancedas the URL.

3. Go to the bottom of the page. Click on the Settings button under the Network Settings.

Settings

4. On the new pop up window, check Manual proxy configuration.

pop_up-manual_proxy_config

  1. HTTP Proxy: Enter localhost or IP address of your system
  2. Port: Enter 8888.

manual_proxy_config 5. Click on the checkbox Use this proxy server for all protocols.
6. Click on the OK button. This should return you to the browser.

Google Chrome Setup:

  1. Open Google Chrome.
  2. Go to the main menu on the right-hand side
  3. Select Settings from the list.

main_menu_settings

  1. Go to Advanced->Accessibility in the left side menu.

advanced_accessiblity

  1. Click on Open your computer's proxy settings.
  2. Turn ON the manual proxy setup. Enter localhost in Address and 8888 in Port.
  3. Click on the Save button.

HTTP Requests

JMeter Recorder Template is the easiest way to get started with recording HTTP requests.

1. Launch JMeter in GUI Mode.
2. Click on Files->Templates.
3. In the dialog box that appears, select Recording with Think Time in the drop-down list Select Template.

templates 4. Click on the Create button
5. You will see a list of attributes that you can configure.

user_defined_var

  1. User-Defined Variables: This lets you define initial set of variables, just as in Test Plan.

user_def_var

  1. HTTP Requests Defaults: This lets you set default values for the variables that the HTTP Request controller can use.

HTTP_req_default

  1. HTTP Cookie Manager: Job of HTTP Cookies Manager is to store and sends cookies just like a web browser do.

HTTP_cookie

  1. Thread Group: Thread Group consists of the request being recorded by JMeter's proxy. Thread Group has a Recording Controller inside it.

Thread_group Recording Controller:

recording_controller

  1. HTTP(S) Test Script Recorder: This is the main component that is responsible for controlling JMeter's Proxy Settings.

https_test_recorder HTTP Test Script Recorder Settings:

If you carefully observe the HTTP Test Script Recorder Settings window. You will observe that there are 3 types of Settings that need to be done:

1. Global Settings: This has 2 fields:

  1. Port: This is the TCP Port on which HTTP or HTTPS Proxy will be running, listening for HTTP requests.
  2. HTTPS Domain: This is the list of Domain Names or we can say Host Names for HTTPS.

2. Test Plan Content: There are 3 fields:

  1. Target Controller: Recording Controller by defaults records everything, every interaction with the web browser. But it is possible to change to whatever you want to record.
  2. Grouping: HTTP requests are grouped to determine which requests belong to the same page.
  3. Capture HTTP Headers: Creates HTTP Headers Manager which will capture the headers sent by the web browser.

3. HTTP Sampler Settings:

  1. Use Keep-Alive: enable HTTP Keep-Alive to signal that connection should be kept open  for further messages.
  2. Follow Redirects: generates only one HTTP request when multiple HTTP redirections are detected and enable Follow Redirects on it.

6. In the HTTP Request Defaults element:

  1. Enter Server Name or IP: frugaltesting.com
  2. Leave all other fields as it is.

7. Return to HTTP(S) Test Script Recorder, and click the Start Button at the top.

Clicking on the Start button will start the JMeter Proxy Server to intercept the browser requests. Please Note this setup was for HTTP Requests. For HTTPS Requests you need to setup JMeter CA Certificate.

If any user enters the URL that is not HTTP. JMeter will show a message that

root_certificate Root CA Certificate is created in JMETER_HOME/bin directory. You need to install this certificate in your browser. The validity of this certificate is 7 days. In the next blog post, we will be discussing with you how to install the ROOT CA Certificate and will also tell you a hack to increase the validity of this certificate so that you don't need to update it after every 7 days.

You might also like