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.
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_ENABLEDfeature 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.
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.
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.
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.
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.
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.

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.

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
OPTIONSrequests, which the browser sends on its own.Responses served from the browser cache or a service worker, and
304 Not Modifiedresponses.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, andSec-*. 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
201and204, 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
passwordorsecretfields, 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.
What each engine receives
One recording produces an equivalent script for each engine, written the way that engine's users expect.
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_URLin Advanced Options. The Host URL field setsHOST_URL, which the generated script does not read.Python: Enter the URL in Host URL, or add an environment variable named
BASE_URLin Advanced Options.Java: Set
BASE_SCHEME,BASE_HOST, and, for a non-default port,BASE_PORTon 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
truewith a Duration (s).

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 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
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
Next steps
Go to JavaScript, Python, or Java to tune the generated test with thresholds, distributed execution, and advanced options.
Go to Analyze load test results to read the run page.
Go to Run in a pipeline to replay the recorded flow on every release.
Last updated
Was this helpful?
