Skip to content
  • ZipCode Api
  • Blog
  • About RedLine13
RedLine13
RedLine13
Primary Navigation Menu
Menu
  • Start Testing
  • Demo
  • Pricing
  • JMeter
  • Partners
  • Docs
    • Documentation Home
    • AWS Set Up for load testing
    • AWS Approval for Large Tests
    • PHP, NodeJS, Python Load Tests
    • Scalability
    • Jenkins Plugin Setup
    • Premium Features
    • Knowledge Base

The k6 Browser Recorder

By: David Koziel

The k6 Browser Recorder

When creating your test plans in k6, it is a common practice to write the script with a bottom-up approach. In other words, each request is explicitly coded in sequence with a series of http request methods wrapped in flow control. While this method provides the ultimate means of control, tests can also be built using the k6 Browser Recorder. With this alternative, a browser plugin allows you to record a series of interactions with a page. These interactions can then be directly converted to a k6 test script. In this post, we will show you how to get started with the k6 Browser Recorder to automate the creation of a k6 test.

Installing and Using the Browser Plugin

The official k6 Browser Recorder is provided by Grafana Labs, and can be added to Chrome or Firefox as an extension. This utility allows you to record browser interactions with any website. To begin a new session with the k6 Browser Recorder, simply click “Start recording” on from the plugin menu:

Click the Start recording button to begin a new session with the k6 Browser Recorder
Click “Start recording” to begin a new session with the k6 Browser Recorder.

Once you are finished recording, simply click the “Stop” button. The recorded session will automatically be downloaded to your computer. If you are signed in to your Grafana Labs account, recordings can also be saved to the cloud.

The stop button will end the active recording.

Preparing your Test Script

The recorded script can be downloaded as a .har file, which is a JSON representation of the interactive browser session. Per the official k6 documentation, you will need to use the har-to-k6 converter to convert this file into a k6 test script. This requires the npm JavaScript package manager to install and use on your local machine:

npm install --save har-to-k6

To convert your saved .har file, use the following command:

npx har-to-k6 your_recorded_session.har -o your_k6_script.js

Replace “your_recorded_session.har” with the file downloaded by the k6 Browser Recorder, and replace “your_k6_script.js” with a name of your choosing.

Running your Recorded Test

Once you have converted the downloaded .har file into a k6 test script, you can use k6 to run the script as-is, or open it for further modification. If you want to debug your test locally, please see our guide on running k6 tests on your local machine. Running your k6 test on RedLine13 is easy, and we have a quick start guide in our documentation which outlines all the steps and the most common test options.


Did you know that RedLine13 offers a full-featured, time-limited free trial? Sign up now, and move you k6 testing into the cloud today!

2024-03-28
Previous Post: Setting k6 Environment Variables
Next Post: Large-Scale and Distributed Load Testing with k6

Recent Posts

  • JMeter XML Format Post Processor
  • Order of Elements in JMeter
  • The JMeter Synthesis Report
  • Using the JMeter Plugins Manager
  • JMeter Rotating JTL Listener

Related

  • JMeter XML Format Post Processor
  • Order of Elements in JMeter
  • SAML Configuration with Azure AD and RedLine13
  • SAML Configuration with OKTA and RedLine13
  • SAML Configuration with Google and RedLine13
  • The JMeter Synthesis Report
  • Using the JMeter Plugins Manager
  • JMeter Rotating JTL Listener
  • Using Test Fragments in JMeter Tests
  • Step-by-Step Guide to Testing with JMeter

© RedLine13, LLC | Privacy Policy | Contract
Contact Us: info@redline13.com

Designed using Responsive Brix. Powered by WordPress.