Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,26 @@ const createRedirects = ({ actions }) => {
isPermanent: true,
});

createRedirect({
fromPath: '/test-authoring/recording-a-session/browser-recorder',
toPath:
'/test-authoring/create-tests-from-recordings/using-the-browser-recorder/',
isPermanent: true,
});

createRedirect({
fromPath: '/test-authoring/recording-a-session/har-converter',
toPath:
'/test-authoring/create-tests-from-recordings/using-the-har-converter/',
isPermanent: true,
});

createRedirect({
fromPath: '/test-authoring/recording-a-session',
toPath: '/test-authoring/create-tests-from-recordings/',
isPermanent: true,
});

const redirects = {
'/javascript-api/k6-http/cookiejar-k6-http':
'/javascript-api/k6-http/cookiejar/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Besides writing a test in your text editor or IDE, you can also use a k6-support

- The [Test builder](/test-authoring/test-builder) is a graphical test builder.
- The [Script editor](/cloud/creating-and-running-a-test/script-editor) is a web-based editor in k6 cloud.
- [Browser recorders](/test-authoring/recording-a-session/browser-recorder) create scripts from recorded sessions.
- [Browser recorders](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/) create scripts from recorded sessions.
- [Converters](/integrations#converters) create tests from HAR, Postman, and OpenAPI files

## Running a cloud test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: 'Browser Recorder'
redirect: 'https://k6.io/docs/test-authoring/recording-a-session/browser-recorder'
redirect: 'https://k6.io/docs/test-authoring/create-tests-from-recordings/using-the-browser-recorder/'
---
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In a load testing scenario, correlation means extracting one or more values from
of one request and then reusing them in subsequent requests. Often, this could be getting
a token or some sort of ID necessary to fulfill a sequence of steps in a user journey.

The [browser recording](/test-authoring/recording-a-session/) will capture session data such as CSRF tokens,
A [recording](/test-authoring/create-tests-from-recordings/) will capture session data such as CSRF tokens,
VIEWSTATES, nonce, etc. This type of data is unlikely to be valid when
you run your test, meaning you'll need to handle the extraction of this data from the HTML/form
to include it in subsequent requests. This issue is fairly common with any site that has forms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If you need a place to test k6 scripts, you can load these servers as much as yo

- [Kubernetes Operator](https://k6.io/blog/running-distributed-tests-on-k8s/). Distribute test execution across a Kubernetes cluster.
- [xk6 extensions](/extensions). Custom k6 binaries to support the tool you need.
- [The browser recorder](/test-authoring/recording-a-session/browser-recorder/). Make test scripts from browser sessions.
- [The browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/). Make test scripts from browser sessions.
- [k6 TypeScript template](https://github.com/grafana/k6-template-typescript)
- [Integrations](/integrations/)

Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Check out the script to get familiar with the [k6 API](/javascript-api/) or to c
- Add a [check](/javascript-api/k6/check) on a request response.
- Add [sleep](/javascript-api/k6/sleep) time between requests.
- Add a [group](/javascript-api/k6/group) to the test.
- Import recorded requests using the [browser recorder](/test-authoring/recording-a-session/browser-recorder).
- Import recorded requests using the [browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/).
- Import requests included in a [HAR file](<https://en.wikipedia.org/wiki/HAR_(file_format)>).
- Capture a variable when dealing with dynamic data, such as authentication tokens.
- Show relevant examples.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: 'Create tests from recordings'
excerpt: 'In load testing, recording usually refers to the process of creating a load test from the recording of a user session.'
---

A recording stores the sequence of requests and parameters of a user session or API interaction.
You can use this recording to auto-generate your test logic.

Testers commonly use recordings to avoid writing complex tests from scratch.
For example, testing advanced scenarios on websites or mobile applications, such as end-to-end (E2E) tests with dozens or hundreds of requests.

k6 provides two tools that can directly convert a recording into k6 script:

- [Browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/) generates a k6 script from a browser session.
- [HAR converter](/test-authoring/create-tests-from-recordings/using-the-har-converter/) generates a k6 script from the requests included in a HAR file.

## Steps

The steps to create a load test from a recording are as follows:

1. Record a user or API session.
2. Convert the recorded session into a test.
3. Set up the load and test options.
4. Handle [correlation and dynamic data](/examples/correlation-and-dynamic-data/).

You can then debug or run the load test.

## Be sure to record realistically

If you use a browser to simulate a user session and generate its recording, consider the following dos and don'ts.

It's a good idea to:
- Browse as a user would.
- Take natural pauses that users would take to consume page content.
- Focus on the most common use cases, rather than all the possible use cases.
- Take note of pages where forms/logins occur. You will need to edit the script to [handle correlation](/examples/correlation-and-dynamic-data/).

You probably _do not_ want to:
- Visit every page in one journey.
- Click every possible option.
- Navigate as fast as you can.
- Navigate out of your actual site or application.

## Consider hybrid approach for load testing websites

When you start the recording and navigate as a user, the recorder captures every HTTP(s) request loaded into the browser as you click. This includes all the requests for third-party services, ads, images, documents, etc.

When you finish the recording, the converter generates the k6 script from all the recorded requests and assets.
The script could include **dozens or hundreds of requests for each page visit or interaction**.

These types of recorded tests are difficult to maintain. As the website changes, these tests must be updated to reflect assets and API changes.

An alternative approach to load test websites is to run a [hybrid load test](https://k6.io/docs/testing-guides/load-testing-websites/#hybrid-load-testing) which:
- Runs a [browser test](/using-k6-browser/running-browser-tests/) to validate the frontend.
- While simultaneously running API tests to inject load to the backend.

As the browser test automatically handles website assets, these tests require fewer updates.

To learn more about this approach, check out the [example mixing browser-level and protocol-level tests](/using-k6-browser/running-browser-tests/#run-both-browser-level-and-protocol-level-tests-in-a-single-script).

Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
---
title: 'Browser recorder'
title: 'Using the browser recorder'
excerpt: 'The browser recorder allows generating a k6 script based on a web session. It is available as extensions for Chrome and Firefox.'
---

The browser recorder lets you generate a k6 script based on a web session.
The browser recorder lets you generate a k6 script based on a browser session.
It's available as an extension for [Chrome](https://chrome.google.com/webstore/detail/k6-browser-recorder/phjdhndljphphehjpgbmpocddnnmdbda?hl=en) and [Firefox](https://addons.mozilla.org/en-US/firefox/addon/k6-browser-recorder/).

## k6 Cloud integration

The browser recorder integrates with [k6 Cloud](/cloud).
When you finish recording the session, the extension uploads the auto-generated k6 test into the k6 Cloud account.
## Before you start

> **Note**: **the recorder is free to use**.
>
>You do not need an active k6 Cloud subscription.
>
> Any user can copy the script from the [script editor](/cloud/creating-and-running-a-test/script-editor) to edit or run the test locally using the `k6 run` command. We also plan to make this feature work without a k6 Cloud account.
Before you start, consider the following:

- [Be sure to record realistically](/test-authoring/create-tests-from-recordings/#be-sure-to-record-realistically)
- [A hybrid approach for load testing websites](/test-authoring/create-tests-from-recordings/#consider-hybrid-approach-for-load-testing-websites)

The recorder captures every HTTP(s) request loaded into the browser as you click.
This includes including ads, images, documents, etc.

## How to record

<Blockquote mod="note" title="The recorder is free to use">

The browser recorder requires a [k6 Cloud account](https://app.k6.io), but you do not need an active k6 Cloud subscription.

When you finish recording the session, the browser extension uploads the auto-generated k6 test into your k6 Cloud account. You can then copy the script to edit it in your local IDE and run the test locally using the `k6 run` command.

</Blockquote>

1. Install the [Chrome](https://chrome.google.com/webstore/detail/k6-browser-recorder/phjdhndljphphehjpgbmpocddnnmdbda?hl=en) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/k6-browser-recorder/) extension.
1. Open the extension by clicking the k6 logo.
1. Select **Start recording** to begin recording the current browser tab.
Expand All @@ -31,7 +34,7 @@ This includes including ads, images, documents, etc.
1. Save the recorded script in any of your projects.
To include some of the requests in the _third party list_, deselect the ones you want to include.
![Step 4](./images/Recording-a-test-script/step-4.png)
1. Edit your script as necessary. Depending on the type of testing, you might need to change different aspects of the script.
1. Edit your script as necessary. Depending on the [type of load test](/test-types/load-test-types/), you might need to change different aspects of the script.
Typical changes are for [load options](/using-k6/options) and to handle [correlation and dynamic data](/examples/correlation-and-dynamic-data).
1. Run the test locally or in k6 Cloud.

Expand All @@ -43,7 +46,7 @@ For more about running k6, refer to the [Running k6 guide](/get-started/running-
## Trouble? Try the HAR converter

Some users have reported `413` errors when they try to upload long recordings.
In these cases, the easiest fix is to use the [HAR converter](/test-authoring/recording-a-session/har-converter/), which creates a k6 script from the HTTP requests included in a HAR file (it also powers the browser recorder).
In these cases, the easiest fix is to use the [HAR converter](/test-authoring/create-tests-from-recordings/using-the-har-converter/), which creates a k6 script from the HTTP requests included in a HAR file (it also powers the browser recorder).

Besides avoiding the `413` error,
the HAR converter catches some edge-case behavior that the browser recorder won't.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
---
title: 'HAR converter'
title: 'Using the HAR converter'
excerpt: 'The HAR converter is an alternative to the Browser recorder. It generates a k6 script based on the HTTP requests included on a HAR file.'
---

The HAR converter is an alternative to the [Browser recorder](/test-authoring/recording-a-session/browser-recorder).
It generates a k6 script based on the HTTP requests included in a [HAR file](<https://en.wikipedia.org/wiki/HAR_(file_format)>).
The [har-to-k6 converter](https://github.com/k6io/har-to-k6) is a NodeJS tool that generates a k6 script based on the HTTP requests included in a [HAR file](<https://en.wikipedia.org/wiki/HAR_(file_format)>).
It is an alternative to the [Browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/).

> HAR is a file format used by all major browsers and various other tools to export recorded HTTP requests.

The [har-to-k6 converter](https://github.com/k6io/har-to-k6) is a NodeJS tool.
Unlike the Browser Recorder, it _does not_ require a k6 Cloud user to generate the k6 script.

Turning a HAR file into a test follows this sequence:

1. Record a HAR file. You can use your browser or your tool of choice.
1. Use the `har-to-k6` converter to generate a k6 test from the HAR file.
1. Update the auto-generated k6 test in your text editor or IDE.
1. Use k6 to run the test.

## Before you start

Before you record your HAR file, you'll need to choose your tool.
You'll also want to consider how you'll record a plausible user session.
Before you start, consider the following:

- [Be sure to record realistically](/test-authoring/create-tests-from-recordings/#be-sure-to-record-realistically)
- [A hybrid approach for load testing websites](/test-authoring/create-tests-from-recordings/#consider-hybrid-approach-for-load-testing-websites)

You'll need to choose a tool to record your HAR file.
Multiple browsers and tools can export HTTP traffic in a HAR format.
A few popular ones are:

Expand Down Expand Up @@ -163,8 +156,3 @@ $ k6 run loadtest.js
```

To learn about running k6, check out the [Running k6 tutorial](/get-started/running-k6).

## Read more

- [Browser recorder](/test-authoring/recording-a-session/browser-recorder): Chrome and Firefox extensions to generate a k6 script from a browser session.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Happy path
: The default system behavior that happens when a known input produces an expected output. A common mistake in performance testing happens when scripts account only for the best case (in other words, the happy path). Most load tests try to discover system errors, so test scripts should include exception handling.<br/><br/>[Happy path (Wikipedia)](https://en.wikipedia.org/wiki/Happy_path)

HTTP archive
: *(Or HAR file)*. A file containing logs of browser interactions with the system under test. All included transactions are stored as JSON-formatted text. You can use these archives to generate test scripts (for example, with the har-to-k6 Converter).<br/><br/>[HAR 1.2 Specification](http://www.softwareishard.com/blog/har-12-spec/), [HAR converter](/test-authoring/recording-a-session/har-converter/)
: *(Or HAR file)*. A file containing logs of browser interactions with the system under test. All included transactions are stored as JSON-formatted text. You can use these archives to generate test scripts (for example, with the har-to-k6 Converter).<br/><br/>[HAR 1.2 Specification](http://www.softwareishard.com/blog/har-12-spec/), [HAR converter](/test-authoring/create-tests-from-recordings/using-the-har-converter/)

Iteration
: A single run in the execution of the `default function`, or scenario `exec` function. You can set iterations across all VUs, or per VU.<br/><br/>The [test life cycle](/using-k6/test-life-cycle/) document breaks down each stage of a k6 script, including iterations in VU code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function Homepage() {
}
```

[Recording browser traffic](https://k6.io/docs/test-authoring/recording-a-session/browser-recorder/) helps you prototype to test websites on the protocol level.
[Recording browser traffic](https://k6.io/docs/test-authoring/create-tests-from-recordings/using-the-browser-recorder/) helps you prototype to test websites on the protocol level.

### Browser-based load testing

Expand Down Expand Up @@ -249,7 +249,7 @@ When you script a test for a website, consider these recommendations.

### Consider factors that affect script realism

**Record your user journey.** Using the browser recorder can facilitate initial test script creation by capturing all the embedded resources on webpages. Check out the [Session Recording guide](https://k6.io/docs/test-authoring/recording-a-session) to learn more about how to auto-generate your load test from a user session.
**Record your user journey.** Using the browser recorder can facilitate initial test script creation by capturing all the embedded resources on webpages. Check out the [Session Recording guide](https://k6.io/docs/test-authoring/create-tests-from-recordings/) to learn more about how to auto-generate your load test from a user session.

**Correlate data.** Recordings often don't take into account dynamic values that are generated anew each time a request is made. Go through the recorded requests and determine whether you need to [extract values from previous responses](https://k6.io/docs/examples/correlation-and-dynamic-data/) and use parameters in subsequent requests. This practice ensures your VUs behave more like real users would.

Expand Down Expand Up @@ -334,6 +334,6 @@ Load testing websites can be complex due to the number of viable testing approac

- [Browser testing with k6 browser](https://k6.io/docs/using-k6-browser/overview/)
- [Load test types](https://k6.io/docs/test-types/load-test-types)
- [Session recording guide](https://k6.io/docs/test-authoring/recording-a-session)
- [Session recording guide](https://k6.io/docs/test-authoring/create-tests-from-recordings)
- [Determining concurrent users in your load tests](https://k6.io/blog/monthly-visits-concurrent-users)
- [Data correlation in your test script](https://k6.io/docs/examples/correlation-and-dynamic-data)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ Estos recursos te ayudarán a escribir y ejecutar k6 tests en un entorno de test

- [Kubernetes Operator](https://k6.io/blog/running-distributed-tests-on-k8s/). Distribuye la ejecución del test de carga a través de un cluster de Kubernetes.
- [xk6 extensions](/extensions). Extiende k6 con nuevas funcionalidades.
- [The browser recorder](/test-authoring/recording-a-session/browser-recorder/). Create un test desde una sesión en el navegador.
- [The browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/). Create un test desde una sesión en el navegador.
- [k6 TypeScript template](https://github.com/grafana/k6-template-typescript).
- [Integrations](/integrations/).
Loading