For the complete documentation index, see llms.txt. This page is also available as Markdown.
Load TestingHarK6LocustJmeter

From a HAR Recording

Record a user flow in the browser, export it as a HAR file, and convert it into a Python, JavaScript, or Java load test script in Harness Resilience Testing

A HAR (HTTP Archive) file is a recording of every request your browser made while you used an application. Upload one in the Load Test Studio and Harness converts it into a script for the Load Test Engine you selected, so a load test can replay a real user flow, such as signing in and placing an order, instead of hitting a single endpoint.

LOAD TESTING IS BEHIND A FEATURE FLAG

Load Testing is behind a feature flag (CHAOS_LOAD_TESTING_ENABLED). Contact Harness Support to enable it.

What you will learn from this topic

  • How to record a user flow and export it as a HAR file.

  • How Harness converts the recording, and what it keeps, drops, and rewrites.

  • How to point the generated script at another environment and supply credentials.

  • How to turn the single-user replay into a load test and read the results.


Before you begin

  • Load Testing enabled: Your account has the CHAOS_LOAD_TESTING_ENABLED feature flag.

  • Infrastructure: A load test infrastructure that supports the engine you plan to use.

  • A browser with developer tools: Chrome, Edge, or Firefox, to record the flow.

  • A test account: Record the flow with an account and data you are allowed to load test, not a production customer account.


Record the flow

Record only the journey you want to load test. Every request in the recording becomes a step in the script, so a short, focused flow produces a script that is easier to review.

1

Open the developer tools

Open the application in a new browser tab, then open the developer tools and select the Network tab. Turn on Preserve log in Chrome or Edge, or Persist Logs in Firefox, so the recording survives page navigations.

2

Clear the log and perform the flow

Clear the network log, then perform the flow once at a normal pace: sign in, browse, submit a form. Harness keeps the pauses between your actions as think time, so a natural pace produces realistic load.

3

Export the HAR file

In Chrome or Edge, select Export HAR (sanitized) in the Network tab toolbar. In Firefox, right-click any request and select Save All As HAR. Keep the file under 2 MB.


Convert the recording

HAR upload is available for every Load Test Engine in the script upload mode: Upload K6 script for JavaScript, Upload Python script for Python, and Upload JMX / XML / ZIP for Java. It is not available in Using Custom Image mode.

1

Create the load test

Go to Resilience Testing > Load Tests, select New Load Test > Create from scratch, and complete the Overview tab: enter a Name, choose the Infrastructure, and select the Load Test Engine. Select Next.

2

Upload the HAR file

On the Test Configuration tab, drag the .har file onto the upload area, or select the area to browse. The upload area lists .har among the supported formats.

The Test Definition card of a JavaScript load test, with Upload K6 script selected, an empty Host URL field, and the k6 Script File upload area listing .js and .har (browser recording) as supported formats with a 2 MB maximum
3

Review the generated script

Harness converts the recording while the upload area shows Converting HAR recording.... When it finishes, the generated script replaces the upload area and appears in Script Preview, named after the engine: recorded-flow.js, recorded-flow.py, or recorded-flow.jmx. Select Edit inline to change it.

The Test Definition card after a HAR upload, showing recorded-flow.js marked Validated with Replace and Edit inline actions, and a Script Preview of the generated k6 script that starts with a comment saying it was generated from a browser recording
4

Save the test

Set the load you want, as described in Run the generated test, and select Save.

Harness converts the recording in memory and saves only the generated script with the test. The HAR file itself is not stored. Upload a new HAR file with Replace to regenerate the script.


What the conversion does

The converter rewrites the recording so it can be replayed repeatedly and against other environments, rather than copying it request for request.

Keeps the requests that exercise your application: page loads (document), API calls (xhr and fetch), and other requests to the primary host. When the recording does not say which host is primary, Harness picks the host of the page load, or the most frequently called host.

Drops:

  • Static assets, such as images, fonts, stylesheets, and most scripts.

  • CORS preflight OPTIONS requests, which the browser sends on its own.

  • Responses served from the browser cache or a service worker, and 304 Not Modified responses.

  • Requests to known analytics and telemetry domains, and to hosts other than the primary host.

Rewrites:

  • Headers: It removes headers the load generator sets itself, such as Host, Content-Length, Cookie, Accept-Encoding, and Sec-*. Headers that every request shares become script-wide defaults.

  • Steps: It groups requests into named steps, one for each page in the recording. When the recording has fewer than two pages, a pause of 1.5 seconds or longer starts a new step.

  • Think time: It turns the pauses between your actions into sleeps, capped at 5 seconds, so a long break in the recording does not stall the test. Pauses under 100 milliseconds are omitted.

  • Checks: It adds a check to every request: the status class for most responses (2xx or 3xx), the exact code for 201 and 204, and the content type for JSON endpoints.

  • Variables: It moves the base URL into a variable, and moves detected credentials, such as bearer tokens, API keys, and password or secret fields, into variables with no default value. The generated script never contains a recorded credential.

  • Correlation: It reads a CSRF token from the page that issued it and sends the live value in later requests, instead of the expired value from the recording. Cookies are handled by the engine's cookie support for each virtual user.

IDS IN URLS ARE NOT REWRITTEN

A recorded path such as /api/users/usr_8812/profile keeps the recorded ID, because the converter cannot tell whether it is dynamic or the exact record you meant to test. Review these paths and replace dynamic IDs with a value read from an earlier response, or with test data.


What each engine receives

One recording produces an equivalent script for each engine, written the way that engine's users expect.

Engine
Generated file
Script structure
Base URL variable

JavaScript

recorded-flow.js

group() per step, check() per request, sleep() for think time, and options with one user, one iteration, and two thresholds.

BASE_URL, read from __ENV.BASE_URL with the recorded URL as the default.

Python

recorded-flow.py

A SequentialTaskSet with one @task per step, so steps run in the recorded order, and catch_response assertions.

BASE_URL, read from the environment with the recorded URL as the default.

Java

recorded-flow.jmx

A Thread Group with one thread and one loop, a Transaction Controller per step, pauses, and a Response Assertion per sampler.

BASE_SCHEME, BASE_HOST, and BASE_PORT, read with ${__P(name,default)}.

Target another environment

The generated script calls the host you recorded against. To run the same flow against another environment, override the base URL without editing the script.

  • JavaScript: Add an environment variable named BASE_URL in Advanced Options. The Host URL field sets HOST_URL, which the generated script does not read.

  • Python: Enter the URL in Host URL, or add an environment variable named BASE_URL in Advanced Options.

  • Java: Set BASE_SCHEME, BASE_HOST, and, for a non-default port, BASE_PORT on the Property Overrides tab of Variables & Overrides. Harness detects the three properties in the generated plan and lists them there for you.

Supply credentials

Each credential the converter moved into a variable is named after where it was found, such as AUTH_TOKEN for an Authorization header or PASSWORD for a password field, and a comment above it in the script says where it is used. Read the top of the generated script for the list.

  • JavaScript and Python: Add an environment variable with the same name in Advanced Options, and mark it SECRET.

  • Java: Add a property override with the same name.

A request that needs a credential you did not supply is sent without a valid value and fails its check.


Run the generated test

The generated script replays the flow once, with one user, so you can confirm it works before adding load. Set the load in the Load Test Studio rather than in the script.

  • JavaScript: Set Users and Duration (seconds) in Load Profile Overrides. Each user repeats the recorded flow until the duration ends.

  • Python: Set Users, Duration, and Ramp Up Duration in the load configuration.

  • Java: Open the Thread Groups tab of Variables & Overrides and expand the Recorded flow thread group. In the Change column, raise Threads and Ramp-up (s), and either raise Loops or set Scheduler to true with a Duration (s).

The Thread Groups tab of Variables and Overrides for a plan generated from a HAR recording, showing the Recorded flow thread group with Threads, Ramp-up, and Loops set to 1 in the plan, editable Change fields, and the BASE_SCHEME, BASE_HOST, and BASE_PORT values the plan reads

The Java plan defines BASE_URL from BASE_SCHEME and BASE_HOST in the same variables block, so the Load Test Studio shows a note that JMeter leaves it as literal text. The generated samplers read BASE_SCHEME, BASE_HOST, and BASE_PORT directly rather than BASE_URL, so the note does not affect the run.

Start with a short run at a few users to confirm every check passes, then increase the load.

After the run, the generated checks appear in the Checks table on the run page, one row for each request in the flow, with their passed and failed counts. A failing check names the request, which tells you which step of the flow broke under load.

The Checks table of a run of a generated JavaScript test, showing a 97.1 percent pass rate with one row per recorded request, such as GET /posts: status is 2xx or 3xx, and 18 failures on the GET / status check

The JavaScript script also declares two thresholds, http_req_failed: ['rate<0.01'] and http_req_duration: ['p(95)<1000']. When a run crosses one, the run finishes with the code E3006: THRESHOLD_CROSSED. Adjust or remove them to match your performance budget. Go to Analyze load test results to read the rest of the run page.


Limits

Limit
Value

HAR file size

2 MB, the same limit as any script upload.

Conversion time

60 seconds.

Recording format

HAR 1.2, as exported by Chrome, Edge, Firefox, and most HTTP proxies.

Protocols

HTTP requests only. WebSockets, server-sent events, and HTTP/2 push are not converted.

Request bodies

Multipart and binary bodies, such as file uploads, are replayed as recorded and are not parameterized.

Correlation

CSRF tokens and cookies only. Correlate other dynamic values, such as IDs from a create request, by editing the script.

Single sign-on

OAuth and SAML logins record as a chain of redirects that cannot be replayed. Record with a session that is already signed in, and supply the session token as a credential.


Troubleshooting

The file type is not supported

The upload area accepts the script formats of the selected engine plus .har. Check that the file name ends in .har, and rename it if your browser or a tool saved it with another extension.

File exceeds the 2 MB limit

The recording is too large to upload. Record a shorter flow, and clear the network log immediately before you start the flow so earlier requests are not included.

invalid HAR file: it is not valid JSON, or it has no log object at the top level

The file is not a HAR recording, or the export was cut short. Export the HAR file again from the Network tab, and upload it without editing it.

invalid HAR file: it has no entries under log.entries

The recording is empty. Make sure the Network tab was open and recording before you performed the flow, then export again.

this HAR file has nothing to replay

Harness read the recording, but every request was dropped, for example because they were all images, cached responses, or calls to other hosts. The rest of the message names the reason. Record the flow again with the browser cache disabled, and make sure it includes the page loads and API calls you want to test.

The k6 Script File field with the existing script kept in Script Preview and a red message under it reading: this HAR file has nothing to replay: all 1 of its requests were filtered out: 1 of a resource type that is not in the include list

The existing script is kept when a conversion fails, so a failed upload does not overwrite your test.

HAR conversion did not finish within the time limit

The recording took longer than 60 seconds to convert. Record a shorter flow, or split a long journey into several recordings and load tests.

Requests fail with 401 or 403 during the run

The script is missing a credential, or the recorded session expired. Supply each credential variable named at the top of the script, as described in Supply credentials. If the application signs in through single sign-on, record with a session that is already signed in.

A request fails because it sends a stale ID or token

The converter correlates CSRF tokens and cookies only. Select Edit inline, read the value from the earlier response that issues it, and use it in the later request, using the extraction support of the engine.


Next steps

Last updated

Was this helpful?