Skip to content

Commit

Permalink
Add browser page close notice (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Aug 4, 2023
1 parent 1d2d85e commit 913786c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The browser module is the entry point for all your tests, and it is what interac
| [browser.context()](/javascript-api/k6-experimental/browser/context) | Returns the current [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/). |
| [browser.isConnected](/javascript-api/k6-experimental/browser/isconnected) <BWIPT id="453"/> | Indicates whether the [CDP](https://chromedevtools.github.io/devtools-protocol/) connection to the browser process is active or not. |
| [browser.newContext([options])](/javascript-api/k6-experimental/browser/newcontext/) <BWIPT id="455"/> | Creates and returns a new [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/). |
| [browser.newPage([options])](/javascript-api/k6-experimental/browser/newpage) <BWIPT id="455"/> | Creates a new [Page](/javascript-api/k6-experimental/browser/page/) in a new [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) and returns the page. |
| [browser.newPage([options])](/javascript-api/k6-experimental/browser/newpage) <BWIPT id="455"/> | Creates a new [Page](/javascript-api/k6-experimental/browser/page/) in a new [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) and returns the page. Pages that have been opened ought to be closed using [`Page.close`](/javascript-api/k6-experimental/browser/page/close/). Pages left open could potentially distort the results of Web Vital metrics. |
| [browser.version()](/javascript-api/k6-experimental/browser/version/) | Returns the browser application's version. |

### Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ A 1-to-1 mapping between [Browser](/javascript-api/k6-experimental/browser) and

</Blockquote>

<Blockquote mod="attention" title="">

Pages that have been opened ought to be closed using [`Page.close`](/javascript-api/k6-experimental/browser/page/close/). Pages left open could potentially distort the results of Web Vital metrics.

</Blockquote>

<TableWithNestedRows>

| Parameter | Type | Default | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ To run a simple local script:

The preceding code imports the `browser` ([the browser module](/javascript-api/k6-experimental/browser)), and uses its `newPage` method to open a new page.

After getting the page, you can interact with it using the [Page](/javascript-api/k6-experimental/browser/page) methods. This example visits a test URL and takes a screenshot of the page. Afterwards, it closes the page.
After getting the page, you can interact with it using the [Page](/javascript-api/k6-experimental/browser/page) methods. This example visits a test URL and takes a screenshot of the page.

Subsequently, the page is closed. This allows for the freeing up of allocated resources and enables the accurate calculation of [Web Vital metrics](/using-k6-browser/browser-metrics/).

<Blockquote mod="note" title="">

Expand Down

0 comments on commit 913786c

Please sign in to comment.