Tutorials 17 October 2018

The Easiest Way to Create (Realistic) Load Test Scripts

John Emmitt

📖What you will learn

  • How to create realistic test scripts that capture a typical user journey in your system
  • How to use the k6 Chrome Extension to record a browser session

So, you want to load test your website or web application to see if it will handle the expected normal and peak user traffic. How can you create a realistic test script that captures a typical user journey in your app?

The easiest way to do this is to record a browser session. Use a tool such as the Load Impact k6 Test Script Recorder, available in the Chrome Web Store.

k6 Test Script Recorder in Google Web Store

The Load Impact k6 Test Script Recorder allows you to capture a typical user session simply by browsing like a user would on your site, or by doing various tasks in your web app. It will capture everything – every single HTTP(s) request being generated by the browser as you click – including ads, images, documents, etc., so you get a far more accurate test of your site or app.

The recorder will not record other browser tabs or pop up windows. If you need to capture this type of activity, you should check out this article: How to convert HAR to k6 test.

Here are the steps to start using the Load Impact k6 Test Script Recorder:

1. Download Chrome Extension

k6 browser recorder in Chrome Web Store

2. Start Recording

Open the recorder by clicking on the Load Impact icon in the upper right corner of your browser window, press "Start recording,” and start browsing in your current browser tab.

web-recorder-step-2

3. Stop Recording

When done browsing, click "Stop" recording. You'll be taken to the Load Impact app to review the test script.

To create your k6 account click here

web-recorder-step-3

4. Save your test script

Save the recorded test script in any of your k6 projects, review the code and click "run."

web-recorder-step-4

The test script that you get as a result of recording a browser session is JavaScript. You can edit this script in the Load Impact in-app script editor. This allows you to create more complex test scripts, as needed. For example, you may want to use parameterized data to handle a login process. The sky's the limit once you have a realistic user test scenario!

< Back to all posts