You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/data/markdown/translated-guides/en/03 Using k6 browser/04 Migrating to k6 v0-46.md
-22Lines changed: 0 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,6 @@ Users no longer need to use the `K6_BROWSER_ENABLED` flag when running browser t
16
16
17
17
</Blockquote>
18
18
19
-
20
19
## Before and after comparison
21
20
22
21
Let's start with an overview of the primary differences between the previous and new versions of the k6 browser API. Subsequent sections will delve into each difference in detail.
@@ -77,7 +76,6 @@ export default async function () {
77
76
78
77
</CodeGroup>
79
78
80
-
81
79
## Key changes
82
80
83
81
The updated version introduces notable structural changes in its operation and API. Let's take a look at them.
@@ -88,9 +86,6 @@ The updated version introduces notable structural changes in its operation and A
88
86
*[Simplified resource management](#simplified-resource-management). The browser module now handles the startup and shutdown of browser processes automatically. `chromium.launch()`, `chromium.connect()`, and `browser.close()` methods are no longer necessary, as these methods have been removed.
89
87
*[Single browser context per iteration](#browser-context-limit). Users can now only run a single [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) at a time in the same iteration.
90
88
91
-
92
-
93
-
94
89
## Import path
95
90
96
91
Changes have been made to how the [browser module](/javascript-api/k6-experimental/browser/) is imported. With the browser type (specifically `chromium`) now set in [scenario options](#scenario-options), users should directly import the [browser](/javascript-api/k6-experimental/browser/#browser-module-api) object from the [browser module](/javascript-api/k6-experimental/browser/). Previously, users relied on `chromium.launch()` for accessing a running browser. Now, a simple import of the [browser](/javascript-api/k6-experimental/browser/#browser-module-api) is sufficient.
@@ -111,10 +106,6 @@ import { browser } from 'k6/experimental/browser';
111
106
112
107
</CodeGroup>
113
108
114
-
115
-
116
-
117
-
118
109
## Browser options
119
110
120
111
In k6 v0.46.0, the need to manually start a browser via `chromium.launch()` or `chromium.connect()` and set its configuration through these methods has been removed, so this part can simply be omitted from test scripts. Users can still change some browser settings by using environment variables. For more information, refer to the [browser module options](/javascript-api/k6-experimental/browser/#browser-module-options) documentation.
The following browser options are no longer supported: `devtools`, `env`, and `proxy` since they weren't providing much value. Although `slowMo` has been temporarily removed, we're working on reintroducing it.
167
157
168
158
</Blockquote>
169
159
170
-
171
-
172
-
173
160
## Scenario options
174
161
175
162
In k6 v0.46.0, users must set the [executor](/using-k6/scenarios/executors/) and browser type as options in a [k6 scenario](/using-k6/scenarios/) definition. Specifically, the `browser.type` option should be set to `chromium`, as Chromium is the only browser supported.
@@ -202,7 +188,6 @@ Now, all that is needed is to specify the browser type within the [scenario opti
202
188
203
189
This change allows to identify the test as a browser test and provides automatic control of the browser's lifecycle. Users no longer need to start or stop the browser manually through the browser API. If the `browser.type` option is set in the scenario options, a browser instance will automatically start at the beginning and close at the end of each test iteration.
204
190
205
-
206
191
## Opening a new page
207
192
208
193
Users can open a new page by using the imported [browser](/javascript-api/k6-experimental/browser/#browser-module-api) object's [browser.newPage()](/javascript-api/k6-experimental/browser/newpage) method. Users can still use the [Page](/javascript-api/k6-experimental/browser/page/) object as before.
@@ -226,9 +211,6 @@ Closing of the page is critical for the calculation of accurate Web Vital metric
226
211
227
212
</Blockquote>
228
213
229
-
230
-
231
-
232
214
## Simplified resource management
233
215
234
216
As [mentioned earlier](#scenario-options), in the new API, there's a shift in how the browser's lifecycle is managed.
@@ -256,9 +238,6 @@ page.close();
256
238
257
239
</CodeGroup>
258
240
259
-
260
-
261
-
262
241
## Browser context limit
263
242
264
243
The new browser implementation limits the usage to a single active [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) per iteration. This change enhances the prediction of resource requirements for a test run and promotes the use of [scenarios](/using-k6/scenarios/) to separate independent browser sessions.
These updates make the usage of our API more straightforward for users, aiding in more consistent and automatic resource management.
307
285
308
286
For all the details, make sure to review the complete changelog for [k6 version 0.46](https://github.com/grafana/k6/releases/tag/v0.46.0). For more information watch [k6 Office Hours #98](https://www.youtube.com/watch?v=fK6Hpvt0pY0), where we discuss the latest changes in k6 browser, and, as always, ask in [the community forum](https://community.grafana.com/c/grafana-k6/k6-browser/79) if you need our help!
0 commit comments