Skip to content

Commit ee9a94a

Browse files
Session recorder and hybrid performance (#1177)
* Restructure `Recording a session` docs * Update `Create tests from recordings` * Reedit create tests from recordings * Complete Rewrite `Create tests from recordings` * Update internal links * Update src/data/markdown/translated-guides/en/05 Test authoring/02 Create tests from recordings.md Co-authored-by: Matt Dodson <[email protected]> * Update src/data/markdown/translated-guides/en/05 Test authoring/02 Create tests from recordings/01 Using the browser recorder.md Co-authored-by: Matt Dodson <[email protected]> --------- Co-authored-by: Matt Dodson <[email protected]>
1 parent a3f60ef commit ee9a94a

File tree

22 files changed

+120
-92
lines changed

22 files changed

+120
-92
lines changed

gatsby-node.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,26 @@ const createRedirects = ({ actions }) => {
16091609
isPermanent: true,
16101610
});
16111611

1612+
createRedirect({
1613+
fromPath: '/test-authoring/recording-a-session/browser-recorder',
1614+
toPath:
1615+
'/test-authoring/create-tests-from-recordings/using-the-browser-recorder/',
1616+
isPermanent: true,
1617+
});
1618+
1619+
createRedirect({
1620+
fromPath: '/test-authoring/recording-a-session/har-converter',
1621+
toPath:
1622+
'/test-authoring/create-tests-from-recordings/using-the-har-converter/',
1623+
isPermanent: true,
1624+
});
1625+
1626+
createRedirect({
1627+
fromPath: '/test-authoring/recording-a-session',
1628+
toPath: '/test-authoring/create-tests-from-recordings/',
1629+
isPermanent: true,
1630+
});
1631+
16121632
const redirects = {
16131633
'/javascript-api/k6-http/cookiejar-k6-http':
16141634
'/javascript-api/k6-http/cookiejar/',

src/data/markdown/docs/03 cloud/01 Creating and running a test/01 Test authoring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Besides writing a test in your text editor or IDE, you can also use a k6-support
1313

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

1919
## Running a cloud test
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: 'Browser Recorder'
3-
redirect: 'https://k6.io/docs/test-authoring/recording-a-session/browser-recorder'
3+
redirect: 'https://k6.io/docs/test-authoring/create-tests-from-recordings/using-the-browser-recorder/'
44
---

src/data/markdown/docs/05 Examples/01 Examples/04 correlation-and-dynamic-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In a load testing scenario, correlation means extracting one or more values from
2020
of one request and then reusing them in subsequent requests. Often, this could be getting
2121
a token or some sort of ID necessary to fulfill a sequence of steps in a user journey.
2222

23-
The [browser recording](/test-authoring/recording-a-session/) will capture session data such as CSRF tokens,
23+
A [recording](/test-authoring/create-tests-from-recordings/) will capture session data such as CSRF tokens,
2424
VIEWSTATES, nonce, etc. This type of data is unlikely to be valid when
2525
you run your test, meaning you'll need to handle the extraction of this data from the HTML/form
2626
to include it in subsequent requests. This issue is fairly common with any site that has forms

src/data/markdown/translated-guides/en/01 Get started/05 resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ If you need a place to test k6 scripts, you can load these servers as much as yo
3434

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

src/data/markdown/translated-guides/en/05 Test authoring/01 test builder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Check out the script to get familiar with the [k6 API](/javascript-api/) or to c
108108
- Add a [check](/javascript-api/k6/check) on a request response.
109109
- Add [sleep](/javascript-api/k6/sleep) time between requests.
110110
- Add a [group](/javascript-api/k6/group) to the test.
111-
- Import recorded requests using the [browser recorder](/test-authoring/recording-a-session/browser-recorder).
111+
- Import recorded requests using the [browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/).
112112
- Import requests included in a [HAR file](<https://en.wikipedia.org/wiki/HAR_(file_format)>).
113113
- Capture a variable when dealing with dynamic data, such as authentication tokens.
114114
- Show relevant examples.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: 'Create tests from recordings'
3+
excerpt: 'In load testing, recording usually refers to the process of creating a load test from the recording of a user session.'
4+
---
5+
6+
A recording stores the sequence of requests and parameters of a user session or API interaction.
7+
You can use this recording to auto-generate your test logic.
8+
9+
Testers commonly use recordings to avoid writing complex tests from scratch.
10+
For example, testing advanced scenarios on websites or mobile applications, such as end-to-end (E2E) tests with dozens or hundreds of requests.
11+
12+
k6 provides two tools that can directly convert a recording into k6 script:
13+
14+
- [Browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/) generates a k6 script from a browser session.
15+
- [HAR converter](/test-authoring/create-tests-from-recordings/using-the-har-converter/) generates a k6 script from the requests included in a HAR file.
16+
17+
## Steps
18+
19+
The steps to create a load test from a recording are as follows:
20+
21+
1. Record a user or API session.
22+
2. Convert the recorded session into a test.
23+
3. Set up the load and test options.
24+
4. Handle [correlation and dynamic data](/examples/correlation-and-dynamic-data/).
25+
26+
You can then debug or run the load test.
27+
28+
## Be sure to record realistically
29+
30+
If you use a browser to simulate a user session and generate its recording, consider the following dos and don'ts.
31+
32+
It's a good idea to:
33+
- Browse as a user would.
34+
- Take natural pauses that users would take to consume page content.
35+
- Focus on the most common use cases, rather than all the possible use cases.
36+
- Take note of pages where forms/logins occur. You will need to edit the script to [handle correlation](/examples/correlation-and-dynamic-data/).
37+
38+
You probably _do not_ want to:
39+
- Visit every page in one journey.
40+
- Click every possible option.
41+
- Navigate as fast as you can.
42+
- Navigate out of your actual site or application.
43+
44+
## Consider hybrid approach for load testing websites
45+
46+
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.
47+
48+
When you finish the recording, the converter generates the k6 script from all the recorded requests and assets.
49+
The script could include **dozens or hundreds of requests for each page visit or interaction**.
50+
51+
These types of recorded tests are difficult to maintain. As the website changes, these tests must be updated to reflect assets and API changes.
52+
53+
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:
54+
- Runs a [browser test](/using-k6-browser/running-browser-tests/) to validate the frontend.
55+
- While simultaneously running API tests to inject load to the backend.
56+
57+
As the browser test automatically handles website assets, these tests require fewer updates.
58+
59+
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).
60+

src/data/markdown/translated-guides/en/05 Test authoring/02 Recording a session/01 Browser recorder.md renamed to src/data/markdown/translated-guides/en/05 Test authoring/02 Create tests from recordings/01 Using the browser recorder.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
---
2-
title: 'Browser recorder'
2+
title: 'Using the browser recorder'
33
excerpt: 'The browser recorder allows generating a k6 script based on a web session. It is available as extensions for Chrome and Firefox.'
44
---
55

6-
The browser recorder lets you generate a k6 script based on a web session.
6+
The browser recorder lets you generate a k6 script based on a browser session.
77
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/).
88

9-
## k6 Cloud integration
109

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

14-
> **Note**: **the recorder is free to use**.
15-
>
16-
>You do not need an active k6 Cloud subscription.
17-
>
18-
> 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.
12+
Before you start, consider the following:
13+
14+
- [Be sure to record realistically](/test-authoring/create-tests-from-recordings/#be-sure-to-record-realistically)
15+
- [A hybrid approach for load testing websites](/test-authoring/create-tests-from-recordings/#consider-hybrid-approach-for-load-testing-websites)
1916

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

2318
## How to record
2419

20+
<Blockquote mod="note" title="The recorder is free to use">
21+
22+
The browser recorder requires a [k6 Cloud account](https://app.k6.io), but you do not need an active k6 Cloud subscription.
23+
24+
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.
25+
26+
</Blockquote>
27+
2528
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.
2629
1. Open the extension by clicking the k6 logo.
2730
1. Select **Start recording** to begin recording the current browser tab.
@@ -31,7 +34,7 @@ This includes including ads, images, documents, etc.
3134
1. Save the recorded script in any of your projects.
3235
To include some of the requests in the _third party list_, deselect the ones you want to include.
3336
![Step 4](./images/Recording-a-test-script/step-4.png)
34-
1. Edit your script as necessary. Depending on the type of testing, you might need to change different aspects of the script.
37+
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.
3538
Typical changes are for [load options](/using-k6/options) and to handle [correlation and dynamic data](/examples/correlation-and-dynamic-data).
3639
1. Run the test locally or in k6 Cloud.
3740

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

4548
Some users have reported `413` errors when they try to upload long recordings.
46-
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).
49+
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).
4750

4851
Besides avoiding the `413` error,
4952
the HAR converter catches some edge-case behavior that the browser recorder won't.

src/data/markdown/translated-guides/en/05 Test authoring/02 Recording a session/02 Har converter.md renamed to src/data/markdown/translated-guides/en/05 Test authoring/02 Create tests from recordings/02 Using the HAR converter.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
---
2-
title: 'HAR converter'
2+
title: 'Using the HAR converter'
33
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.'
44
---
55

6-
The HAR converter is an alternative to the [Browser recorder](/test-authoring/recording-a-session/browser-recorder).
7-
It generates a k6 script based on the HTTP requests included in a [HAR file](<https://en.wikipedia.org/wiki/HAR_(file_format)>).
6+
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)>).
7+
It is an alternative to the [Browser recorder](/test-authoring/create-tests-from-recordings/using-the-browser-recorder/).
88

99
> HAR is a file format used by all major browsers and various other tools to export recorded HTTP requests.
1010
11-
The [har-to-k6 converter](https://github.com/k6io/har-to-k6) is a NodeJS tool.
12-
Unlike the Browser Recorder, it _does not_ require a k6 Cloud user to generate the k6 script.
13-
14-
Turning a HAR file into a test follows this sequence:
15-
16-
1. Record a HAR file. You can use your browser or your tool of choice.
17-
1. Use the `har-to-k6` converter to generate a k6 test from the HAR file.
18-
1. Update the auto-generated k6 test in your text editor or IDE.
19-
1. Use k6 to run the test.
20-
2111
## Before you start
2212

23-
Before you record your HAR file, you'll need to choose your tool.
24-
You'll also want to consider how you'll record a plausible user session.
13+
Before you start, consider the following:
14+
15+
- [Be sure to record realistically](/test-authoring/create-tests-from-recordings/#be-sure-to-record-realistically)
16+
- [A hybrid approach for load testing websites](/test-authoring/create-tests-from-recordings/#consider-hybrid-approach-for-load-testing-websites)
2517

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

@@ -163,8 +156,3 @@ $ k6 run loadtest.js
163156
```
164157

165158
To learn about running k6, check out the [Running k6 tutorial](/get-started/running-k6).
166-
167-
## Read more
168-
169-
- [Browser recorder](/test-authoring/recording-a-session/browser-recorder): Chrome and Firefox extensions to generate a k6 script from a browser session.
170-
File renamed without changes.

0 commit comments

Comments
 (0)