Performance Testing Using Jmeter Part 1

Performance Testing using JMeter (Part 1)- Start with Recording a Test Script

These days it is expected that every functional or non-functional automation tool should provide record and playback functionality so that testers can write tests that closely mimic a real user interaction with the system. JMeter is an open source, powerful load testing tool that provides functionality to record both HTTP and HTTPS requests.

In this blog, I will explain all the steps you need to perform to record both http and https requests.

Browser Configurations: –

Before Starting with the recording process, we need to change some configuration settings of the browser. Here, I am explaining all those settings for Firefox browser.

  • Open Preferences for Firefox (using Firefox->Preferences on Mac and
    Tools->Options on Windows)
  • Open Network Tab by clicking on Advanced->Network

Firefox Network Settings

  • Click on Settings Button and update proxy setting to localhost: 8080, as shown below: –

HTTP Proxy Settings

  • Click OK Button to save all Settings.

JMeter Configurations: –

Now that we are done with the configuration settings for Internet proxy, we will proceed with JMeter steps.

  • Add a new Thread Group by right clicking on Test Plan -> Add -> Threads -> Threads Group, as shown below: –

Add New Thread Group

  • Add config element HTTP Request Defaults by right clicking on
    Thread Group -> Config element -> HTTP Request Defaults

Add New HTTP Request Defaults

  • Specify the Server Name (website host name) or IP of the server for which you want to record Http requests
  • In the Path specify the relative path of the webpage for which you want to record Http request. If it’s the home page of the , just specify slash(/) in the path, as shown below:-

Path Settings for Home Page

  • Add Recording Controller by right clicking on Thread Group -> Add -> Logic Controller -> Recording Controller as shown below :-

Add New Recording Controller

  • Add HTTP Test Script Recorder by right clicking on WorkBench – > Add -> Non Test Elements -> HTTP(S) Test Script Recorder as shown below :-

Add New HTTP(S) Test Script Recorder

  • If you just want to record HTTP requests for HTML pages, then
    • Click Add suggested Excludes on HTTP(S) Test Script Recorder panel. This will add the URL patterns that we want to exclude from recording.
      > OR
    • Click on Add Button on URL Patterns to Include section and type .*\.html. This specifies that only HTML samplers should be recorded.

Patterns to include and exclude from Recording

And now you are ready with all the needed configurations to start recording.

  • Click on the Start Button on HTTP(S) Test Script Recorder panel. But what, instead of starting recording, JMeter shows a pop-up regarding creation of a certificate as shown below: –

JMeter Security Certificate

  • Actually, all HTTPS connections use certificates to authenticate the connection between the browser and the web server. When the communication protocol is HTTPS, the web-server presents the security certificate to the browser. To authenticate this certificate, the browser checks whether the server certificate is signed by a Certificate Authority (CA) or not.
  • For versions of JMeter from 2.10 onwards, JMeter generates its own certificate(s), which can be imported in the browser to enable the trust between proxy server and browser and also to enable recording of HTTPs requests.

When a pop-up as above for security certificate appears, it will create a file named “ApacheJMeterTemporaryRootCA.crt” in bin directory of JMeter

Now we need to install this certificate in the browser.

We will perform the steps to import the security certificate in Firefox.

  • From the “Certificates” tab click on “View Certificates” and import the certificate created in the above step as shown below: –

Importing Security Certificate in Firefox

And now we are all set to start recording.

  • Ideally, to start recording, use private browsing mode when recording the session. This should ensure that the browser starts with no stored cookies, and prevents certain changes from being saved.

So start firefox in Private Browsing mode with url as

Click on different links, which you want to record in your test plan.

You will see that the links that you click in the browser, starts recording as “Http Request” under the “Recording Controller” as shown below :-

Recorded Http Samplers

Now, you can use these Http samplers with other components of JMeter to create your full-fledged test plans.

So, we are done with first step of JMeter, where we are having all the needed Http Requests ready.

We will discuss about using these Https requests and their collaboration with other JMeter components in further series of blogs.

Leave a Reply

Your email address will not be published. Required fields are marked *