Skip to content

Commit 777eaa8

Browse files
committed
Update browser module imports
Ensure that that the examples import browser and not chromium for the browser module examples throughout the documentation.
1 parent 9aef773 commit 777eaa8

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

docs/sources/next/javascript-api/k6-experimental/browser/locator/dispatchevent.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Dispatches HTML DOM event types e.g. `'click'`.
99

1010
<TableWithNestedRows>
1111

12-
| Parameter | Type | Defaults | Description |
13-
| --------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14-
| type | string | `''` | DOM event type e.g. `'click'`. |
15-
| eventInit | object | `null` | Optional event specific properties. See [eventInit](#eventinit) for more details. |
16-
| options | object | `null` | |
12+
| Parameter | Type | Defaults | Description |
13+
| --------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14+
| type | string | `''` | DOM event type e.g. `'click'`. |
15+
| eventInit | object | `null` | Optional event specific properties. See [eventInit](#eventinit) for more details. |
16+
| options | object | `null` | |
1717
| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/browsercontext/) or [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/page/). |
1818

1919
</TableWithNestedRows>
@@ -35,15 +35,16 @@ Since eventInit is event-specific, please refer to the events documentation for
3535
{{< code >}}
3636

3737
```javascript
38-
import { chromium } from 'k6/experimental/browser';
38+
import { browser } from 'k6/experimental/browser';
3939

4040
export default async function () {
41-
const browser = chromium.launch();
4241
const page = browser.newPage();
4342

4443
await page.goto('https://test.k6.io/browser.php');
4544
const button = page.locator('#counter-button');
4645
button.dispatchEvent('click');
46+
47+
page.close();
4748
}
4849
```
4950

docs/sources/next/testing-guides/load-testing-websites.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,10 @@ The following is an example of a browser-based load testing script in k6 using t
190190
<!-- eslint-skip -->
191191

192192
```javascript
193-
import { chromium } from 'k6/experimental/browser';
193+
import { browser } from 'k6/experimental/browser';
194194
import { sleep } from 'k6';
195195

196196
export default async function () {
197-
const browser = chromium.launch({ headless: false });
198197
const page = browser.newPage();
199198

200199
// 01. Go to the homepage
@@ -217,7 +216,6 @@ export default async function () {
217216
sleep(1);
218217
} finally {
219218
page.close();
220-
browser.close();
221219
}
222220
}
223221
```

docs/sources/next/using-k6-browser/recommended-practices/page-object-model-pattern.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ You can import the `Homepage` class within your test class and invoke the method
7373
{{< code >}}
7474

7575
```javascript
76-
import { chromium } from 'k6/experimental/browser';
76+
import { browser } from 'k6/experimental/browser';
7777
import { expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.0/index.js';
7878

7979
import { Homepage } from '../pages/homepage.js';
8080
import { bookingData } from '../data/booking-data.js';
8181

8282
export default async function () {
83-
const browser = chromium.launch();
8483
const page = browser.newPage();
8584

8685
const { name } = bookingData;
@@ -92,7 +91,6 @@ export default async function () {
9291
expect(homepage.getVerificationMessage()).to.contain(name);
9392

9493
page.close();
95-
browser.close();
9694
}
9795
```
9896

0 commit comments

Comments
 (0)