Skip to content

Commit

Permalink
Update the browser imports for v0.48.x docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Dec 7, 2023
1 parent 5175570 commit 8366244
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Dispatches HTML DOM event types e.g. `'click'`.

<TableWithNestedRows>

| Parameter | Type | Defaults | Description |
| --------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type | string | `''` | DOM event type e.g. `'click'`. |
| eventInit | object | `null` | Optional event specific properties. See [eventInit](#eventinit) for more details. |
| options | object | `null` | |
| Parameter | Type | Defaults | Description |
| --------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type | string | `''` | DOM event type e.g. `'click'`. |
| eventInit | object | `null` | Optional event specific properties. See [eventInit](#eventinit) for more details. |
| options | object | `null` | |
| 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/). |

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

```javascript
import { chromium } from 'k6/experimental/browser';
import { browser } from 'k6/experimental/browser';

export default async function () {
const browser = chromium.launch();
const page = browser.newPage();

await page.goto('https://test.k6.io/browser.php');
const button = page.locator('#counter-button');
button.dispatchEvent('click');

page.close();
}
```

Expand Down
4 changes: 1 addition & 3 deletions docs/sources/v0.48.x/testing-guides/load-testing-websites.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,10 @@ The following is an example of a browser-based load testing script in k6 using t
<!-- eslint-skip -->

```javascript
import { chromium } from 'k6/experimental/browser';
import { browser } from 'k6/experimental/browser';
import { sleep } from 'k6';

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

// 01. Go to the homepage
Expand All @@ -217,7 +216,6 @@ export default async function () {
sleep(1);
} finally {
page.close();
browser.close();
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,13 @@ You can import the `Homepage` class within your test class and invoke the method
{{< code >}}

```javascript
import { chromium } from 'k6/experimental/browser';
import { browser } from 'k6/experimental/browser';
import { expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.0/index.js';

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

export default async function () {
const browser = chromium.launch();
const page = browser.newPage();

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

page.close();
browser.close();
}
```

Expand Down

0 comments on commit 8366244

Please sign in to comment.