Browser Recorder in K6- A Quick Overview

Reading Time: 4 minutes

In this blog, we will learn about generating a k6 test script based on user sessions via the Browser Recorder extension. This extension allows us to capture everything that we have done in browser, and generate a k6 script for us automatically, and link it to our k6 Cloud account.

Note :- k6 comes with two methods for recording a session:

  • Browser Recorder extension — generates a k6 script from a browser session.
  • HAR converter — generates a k6 script from the requests included in an HTTP Archive file.

How to get started with k6 performance testing?
Setting up an account :

Let’s start by setting up a k6 account. To do that, follow this https://app.k6.io/account/register

K6 Registration page

You need to provide your email address and password. Then, you wait to get the activation URL.

Click the ‘Activate Account” button. Congratulations –you’ve just registered your k6 account!

Installing the k6 Browser Recorder plugin

Once you are done with the registration, let’s install the k6 Browser Recorder extension. It supports the following browser:

Firefox Extension

Chrome Extension

You can easily install the k6 Browser Recorder extension via the following URL.In this blog I’m using Chrome extension.

Now, find the “puzzle” icon associated with extensions and use the pin icon to add the plugin to the browser sidebar.

k6 plugin among Chrome extensions

Click on the Browser Recorder extension, and you should see the following pop up:

Image shows “no data recorded yet”
Furthermore, k6 Browser Recorder extension comes with the following functionalities:
  • Download HAR file — capture and save the HTTP Archive file in your Download folder.
  • Clear cache (lasts 7 days) — remove extension cache from the browser.
  • Correlate request/response data — associate a request/response to use a value that was returned by a previous request/response. This ensures a better performance test. Only applicable for Chrome extension at the time of this writing.
  • View history — redirect you to an offline page showing the recording history.

Let’s Start recording :

Next, click the Start Recording button to start recording.The pop up will change to the following user interface:

Simply browse or access any website normally while it is recording. For example :-

I’m using a demo website (OrangeHRM)in which i login into the website by adding credentials and visit the homepage of the site and then logout from site and will stop the recording to see the result.

End recording

Once you are done with it, access the extension and choose one of the following:

  • Stop — ends the recording and links the generated test script to k6 Cloud.
  • Pause — temporarily pause the recording which can be resumed later.
  • Reset — remove current active recording and back to theStart Recording interface.

Click on the Stop button to end the recording. It will automatically open up a new page to K-6 Cloud in your main browser.

The new page opens automatically in a new tab. You can now save the recorded test, name it and set various parameters.

There are now 3 parameters to set:

  1. Correlate request and response data – it automatically detects and sets variables for data returned by the server.
  2. Include static assets – it includes static resources such as fonts, images, CSS, JS files and others.
  3. Generate sleep – it automatically generates a break between requests, which are made in less than 500 ms from each other. 

Now click on the “Save” button.

You are now redirected to the page of the recorded test displayed in the “Builder” mode.

k6 test recording analysis

Launching the test in the Cloud

Click on “RUN” button to conduct the test.

Wait until completed “Setting up test (100%)”. You should see a graphic that says that the test is ready. Wait for resources to be assigned to the test.

The test will begin shortly. You can see the results being generated in real-time, which makes it much easier to understand the whole process.

When the results appear, we can finally start the analysis.

There are a couple of tools to help you with displaying and analyzing the results. In the upper right corner you can click the 3 dots and choose the “Generate PDF summary” button or export the data in a different form:

The “Generate PDF summary” option allows you to download a PDF file, which includes the test results presented clearly in charts and diagrams.

References:

https://k6.io/docs/

Written by 

Sakshi Sneha is Software Consultant in Knoldus Inc. She is always eager to learn new and advanced concepts in order to upskill herself.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading