k6 has a built-in HAR converter that will read HAR files and convert them to k6 scripts that can then be executed:
k6 convert myfile.har
The above command will make k6 read
-O option to save to a file, or just redirect the output on stdout to a file).
You can use the HAR converter to convert HAR files generated by e.g. Firefox or Chrome. This enables you to easily record user sessions for your site/app and then replay those sessions in a k6 load test.
Here are the basic steps you need to take to make a recording in Chrome (Firefox is similar):
Open a new incognito window in Chrome (not really necessary, but using an incognito window means you won't be sending a lot of cookies etc that might have been saved by your browser)
Open up Chrome developer tools (CMD-SHIFT-I on a Mac)
Click the "Network" tab
Click the "Preserve log" checkbox if you want to make a recording of several successive page loads
Go to your site and start doing whatever you'd like your simulated load test users to be doing
When done, right-click on the list of URLs in Chrome developer tools and choose "Save as HAR with content" - see screenshot below
Convert the HAR file using k6:
k6 convert -O myscript.js myfile.har
Run the resulting myscript.js script:
k6 run myscript.js
Recommended is of course to review the script before running it. There may be dynamic data used on your site - CSRF tokens or whatnot - that will be hardcoded into the k6 script and which you may want to replace with dynamic data that k6 gets from the server you are testing.