The HTTP(S) Test Script Recorder allows JMeter to intercept and record your actions while you browse your web application with your normal browser. JMeter will create test sample objects and store them directly into your test plan as you go (so you can view samples interactively while you make them).

Yes, the quote above is clear enough, the Recording feature will help you to create quickly a test plan based on the actions which you’ve performed in your web application. Besides that, it’s also a useful feature for new users to get familiar with JMeter, rather than building a basic test plan by manually.

Note: This post is applicable from JMeter 3.0 or higher. The older version might not work properly.

The tutorial below will show you how to recording the page http://jmeter.apache.org/ on Chrome and Firefox.

Step 1: Open JMeter, click Templates… button in the buttons toolbar.

record-template-button.png

Step 2: In the Templates pop-up, select Recording in the Select Template drop-down list. And click Create button to create a Recording Test Script.

record-template-pop-up

Step 3: You will see the Test Plan with the full element for a Recording Test Script. Please focus to WorkBenchHTTP(S) Test Script Recorder. We have many properties/settings in this element, but just pay attention to the following properties are enough:

  • Port: Default 8888. It’s the port that the HTTP(S) Test Script Recorder listens to. You can change it. And remember that the properly port number should be: 4000 < port number < 65535. For now, just leave it 8888 as default.
  • URL Patterns to Include: Allows filtering of requests that are recorded. All requests pass through, but only those that meet the requirements of the Include (using Regular Expression) fields are recorded.
    • Click Add button in URL Patterns to Include
    • This will create a blank entry; enter .*\.html
      NOTE: this pattern .*\.html means if the request end with .html, it will be recorded, otherwise, it will NOT be recorded. So please careful, if your site does not end with .html, then you can leave it blank.
    • Or you can input the pattern base on your site to record exactly what come from your site.
      Example:

      • my site is jmetervn.com then I will input pattern jmetervn.com.*
      • my site is www. example.com then I will input www. example.com.*
        (please ignore the space between www. and example)
  • URL Patterns to Exclude: Any requests that match one or more Exclude pattern are NOT recorded. Usually, we don’t record all the request such as image (.png, .jpg), css, js, etc. Just leave it as default, JMeter added 2 useful regex.

record-test-script-recorder.png

Step 4: Click Start button at bottom of page:

record-start.png

And then click OK in the Certificate pop-up:

record-cert.png

Step 5: Config your browser to use the JMeter Proxy

  • Firefox
    • Open Firefox
    • Click Menu > Preference
      record-ff-settings-1.png
    • Go to Advance > Network > Settings
      record-ff-settings-2.png
    • Select Manual proxy configuration
    • Input localhost into HTTP Proxy field
    • Input the Port in step 3 above into Port field. In my sample, it’s 8888
    • Click OK.
      record-ff-settings-3.png
  • Chrome (on MAC)
    • Open Chrome
    • Click Menu > Settings
      record-chrome-mac-1.png
    • Search proxy
    • Click Change proxy settings
      record-chrome-mac-2
    • Network pop-up is opened, select Proxies tab
    • Select checkbox Web Proxy (HTTP), Secure Web Proxy (HTTPS), FTP Proxy, and SOCKS Proxy.
    • Input localhost into HTTP Proxy field
    • Input the Port in step 3 above into Port field. In my sample, it’s 8888
    • Click OK.
      record-chrome-mac-3.png
    • Then click Apply in Network pop-up
  • Safari (on MAC)
    • Open Safari
    • In the menu bar, click Safari > Preference
    • Select tab Advanced in the pop-up
    • Click Change Settings… in Proxies field
      record-safari-1.png
    • Network pop-up is opened. Now follow the next steps in Chrome section, it’s the same

Step 6: Now you can start to record your navigation

  • Go to http://jmeter.apache.org/
  • Go to Documentation > Get Started
  • Go to Documentation > User Manual
  • Go to Documentation > Component Reference
  • Go to Documentation > Functions Reference
  • Go to Download > Download Releases

And this is the result, all recorded requests will be stored under Recording Controller

record-jmeter-page-1.png

If you’re wondering why the last request Download > Download Releases didn’t appear here, then the answer is: it’s not the request end with html as the URL Patterns to Include which I defined in step 3 above.

Checking the View Result Tree of HTTP(S) Test Script Recorder, it shows all requests were made during the recording, but only needed requests were being saved to Recording Controller.

Please try this by yourself, the result might difference a bit, but you will improve it after few times.


Recording HTTPS Request

I hope it’s easy for you to record your very first script. But if you’re trying to record an HTTPS website, you might face the error like below:

record-error-1.png
Error on Chrome
record-error-2
Error on Firefox

When you see this error, it means you need to install the certificate before recording an HTTPS website.

Very easy, please do the following step to pass this issue

Firefox:

  • Open Firefox
  • Click Menu > Preference
    record-ff-settings-1
  • Go to tab Advanced > tab Certificates > View Certificates
    record-error-ff-1.png
  • The pop-up is opened, go to Authorities tab > Import
    record-error-ff-2.png
  • Browse to the file ApacheJMeterTemporaryRootCA.crt under /${JMETER_HOME}/bin folder
    Note: This file is only generated after you click Start button in HTTP(S) Test Script Recorder, refer Step 4 above.
    record-error-ff-3.png
  • Select option: Trust this CA to identify websites
    record-error-ff-4.png
  • It will auto go back the Authorities pop-up and show the recent added Certificate of JMeter (check the image below), click OK to finish.
    record-error-ff-5.png

Chrome (on MAC):

  • Open Chrome
  • Open the Menu by clicking the three dot button and select Settings.
    record-chrome-settings-1or just input the following text: chrome://settings in Chrome’s address bar and press enter
    record-chrome-settings-2
  • Input “certificate” into the Search Settings field, then search. And click Manage certificates… button under HTTPS/SSL section
    record-chrome-settings-certificate.png
  • It opens the Keychain Access popup, focus to the Category Certificates, drag and drop the ApacheJMeterTemporaryRootCA.crt file in JMeter /bin folder, and drop it into this.
    Note: This file is only generated after you click Start button in HTTP(S) Test Script Recorder, refer Step 4 above.
    record-chrome-settings-import-cert-1.png
  • After importing into the Certificates category, it will display as untrusted file
    record-chrome-settings-import-cert-2.png
  • Now we must change it to trusted by doing the following: Double Click on this file, and change the option When using this certificate from Use System Defaults to Always Trust.
    record-chrome-settings-import-cert-3
  • Close that pop-up, the user password might be required for this change. When it goes back to Keychain Access pop-up, check if the certificate is installed successfully and trusted now.
    record-chrome-settings-import-cert-4.png

Now you can record the HTTPS website normally.

Advertisements