Skip to content
Tutorials Center
My learning

Topics

Lesson 11 of 37 ยท Test Plans and Samplers

Recording a Script with the JMeter HTTP(S) Test Script Recorder

Record browser traffic into a JMeter test plan with the HTTP(S) Test Script Recorder: proxy setup, certificate, URL filters, grouping into transactions and cleaning up the recording.

Writing every request by hand is slow. JMeter's HTTP(S) Test Script Recorder works as a proxy: you point your browser at it, click through your site, and JMeter records each request as an HTTP Request sampler. A recording is a first draft: it always needs cleaning, parameterizing and correlating before it is a real test.

Honesty note. JMeter cannot run here, so this lesson describes the real recorder workflow in words and as a checklist. The runnable block is a stand-in that takes a list of captured requests (like a browser's HAR export) and applies the same cleanup steps the recorder's filters do.

How the recorder works

flowchart LR
  B["Browser (proxy = localhost:8888)"] --> R["JMeter recorder (man-in-the-middle proxy)"]
  R --> S["Web server"]
  S --> R
  R --> B
  R --> T["Test plan: recorded samplers"]

The recorder forwards every request unchanged and writes a sampler for it in your plan.

For HTTPS, the recorder must decrypt and re-encrypt traffic, so it presents its own certificate. That is why you need to trust JMeter's temporary root certificate in your browser during recording, and remove it afterwards.

Recording steps

  1. Start from the template. Use File > Templates... > Recording. It creates a Thread Group, a Recording Controller, a Transaction setup and an HTTP(S) Test Script Recorder (under Non-Test Elements), already configured sensibly. (You can also add the recorder manually.)
  2. Check the port. The recorder listens on port 8888 by default. Change it if that is in use.
  3. Set the target controller. Target Controller is where recorded samplers are placed; the template uses the Recording Controller. Grouping controls whether each page's requests are grouped (for example Put each group in a new transaction controller).
  4. Set include and exclude patterns. Under Requests Filtering add URL Patterns to Include such as .*example\.test.*, and URL Patterns to Exclude such as .*\.(png|jpg|css|js|woff2?) plus analytics hosts. Filtering keeps the plan free of noise like trackers and static files.
  5. Press Start. JMeter generates the root certificate ApacheJMeterTemporaryRootCA.crt in the bin folder (and a keystore) on first start. Install the certificate as a trusted root in the browser or OS you record with, for test use only.
  6. Configure the browser proxy. Set HTTP and HTTPS proxy to localhost (or 127.0.0.1) port 8888. A dedicated browser profile or a proxy-switcher extension keeps your normal browsing unaffected.
  7. Browse the journey. Do exactly what a user does: open home, search, view product, add to cart. Pause a couple of seconds between steps if you want recorded think time (the recorder can add timers).
  8. Stop the recorder, then undo the proxy setting and remove the temporary certificate from the trust store.

Treat the trust step seriously: anyone holding that private key could intercept your HTTPS traffic while it is trusted. Use a throwaway browser profile, and delete the certificate and keystore when finished.

Alternative: record with browser dev tools

Modern browsers can export a session as a HAR file or copy a request as curl. JMeter's Tools > Import from cURL converts a copied command into a sampler without any proxy or certificate. For API-heavy single-page apps, copying the few important XHR/fetch calls from the Network tab is often cleaner than a full recording. A BlazeMeter Chrome extension that exports a JMX also exists, but a plain proxy recording needs nothing extra.

Clean up the recording

A raw recording is not a test. Always:

  1. Rename samplers: 001 / becomes Home; add numbering for order.
  2. Remove noise: third-party calls, favicon, tracking pixels, duplicate requests.
  3. Move shared settings into HTTP Request Defaults and a Header Manager (the recorder often copies the browser's headers onto every sampler).
  4. Replace hard-coded values with variables: usernames, search terms, ids (see Variables).
  5. Correlate dynamic values: CSRF tokens, session ids, view states must be extracted and reused (covered in the correlation chapter).
  6. Add assertions so an error page is not counted as a success.
  7. Add think time with a timer (Timers).
  8. Replay with one user and compare with the browser behaviour before scaling up.

The stand-in below filters a captured request list and builds plan-like labels.

JS Stand-in: filter captured requests like the recorder

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The result is a short, readable list of real user actions: the right starting point to build a plan from.

Pitfalls and tips

  • Certificate errors in the browser: the root CA is not trusted yet, or you recorded with an old certificate; regenerate by deleting the old keystore and restarting the recorder.
  • Nothing is recorded: check that the browser actually uses the proxy and that your include patterns match the full URL (patterns are regular expressions matched against the whole URL).
  • Mobile apps: point the device's Wi-Fi proxy to the recording machine's IP and trust the certificate on the device. Apps that pin certificates will refuse; use test builds that do not.
  • Cached pages: clear the browser cache before recording, or the browser will not send the requests you want to capture.
  • Corporate proxies: chain JMeter's recorder to the upstream proxy through the settings in system.properties or the -H and -P start options.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the default port of the JMeter HTTP(S) Test Script Recorder?

    The recorder listens on port 8888 unless you change it.
  2. 2. Why must you trust a JMeter certificate in the browser to record HTTPS?

    As a man-in-the-middle proxy the recorder presents its own certificate, so the browser must trust it for the session.
  3. 3. What should always happen after recording?

    A recording contains hard-coded values and noise; it needs cleanup before it is a reliable test.
  4. 4. Which is a recorder-free way to create a sampler from a request seen in browser dev tools?

    Copy the request as cURL and import it as an HTTP Request sampler.

Summary

  • The HTTP(S) Test Script Recorder is a proxy (default port 8888) that writes samplers as you browse.
  • Use the Recording template, include/exclude URL patterns, and a throwaway browser profile.
  • Trust the temporary root certificate only while recording, then remove it.
  • Treat the result as a draft: rename, remove noise, centralize headers, parameterize, correlate, assert, add think time.
  • Import from cURL is a lighter alternative for API requests.

Next: Testing REST APIs and JSON with JMeter