Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: explicitly annotate methods and parameters (#4771)

Pavel Feldman2e220df7acda
diff --git a/docs-src/api-body.md b/docs-src/api-body.md
index 435d243983..2e08da12e9 100644
--- a/docs-src/api-body.md
+++ b/docs-src/api-body.md
@@ -1,8 +1,8 @@
# class: Browser
* extends: [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
-A Browser is created when Playwright connects to a browser instance, either through [browserType.launch()]() or
-[browserType.connect()]().
+A Browser is created when Playwright connects to a browser instance, either through [`method: BrowserType.launch`]() or
+[`method: BrowserType.connect`]().
An example of using a [Browser] to create a [Page]:
@@ -17,9 +17,9 @@ const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
})();
```
-See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific features. Note that
-[browserType.connect()]() and [browserType.launch()]() always return a specific browser instance, based on the browser
-being connected to or launched.
+See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific features. Note that [`method:
+BrowserType.connect`]() and [`method: BrowserType.launch`]() always return a specific browser instance, based on the
+browser being connected to or launched.
<!-- GEN:toc -->
<!-- GEN:stop -->
@@ -28,15 +28,15 @@ being connected to or launched.
Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
* Browser application is closed or crashed.
-* The [browser.close()]() method was called.
+* The [`method: Browser.close`]() method was called.
## async method: Browser.close
-In case this browser is obtained using [browserType.launch()](), closes the browser and all of its pages (if any were
-opened).
+In case this browser is obtained using [`method: BrowserType.launch`](), closes the browser and all of its pages (if any
+were opened).
-In case this browser is obtained using [browserType.connect()](), clears all created contexts belonging to this browser
-and disconnects from the browser server.
+In case this browser is obtained using [`method: BrowserType.connect`](), clears all created contexts belonging to this
+browser and disconnects from the browser server.
The [Browser] object itself is considered to be disposed and cannot be used anymore.
@@ -86,8 +86,8 @@ Creates a new browser context. It won't share cookies/cache with other browser c
Creates a new page in a new browser context. Closing this page will close the context as well.
This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
-testing frameworks should explicitly create [browser.newContext()]() followed by the [browserContext.newPage()]() to
-control their exact life times.
+testing frameworks should explicitly create [`method: Browser.newContext`]() followed by the [`method:
+BrowserContext.newPage`]() to control their exact life times.
### option: Browser.newPage.-inline- = %%-shared-context-params-list-%%
@@ -129,13 +129,13 @@ await context.close();
Emitted when Browser context gets closed. This might happen because of one of the following:
* Browser context is closed.
* Browser application is closed or crashed.
-* The [browser.close()]() method was called.
+* The [`method: Browser.close`]() method was called.
## event: BrowserContext.page
- <[Page]>
The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
-also fire for popup pages. See also [page.on('popup')]() to receive events about popups relevant to a specific page.
+also fire for popup pages. See also [`event: Page.popup`]() to receive events about popups relevant to a specific page.
The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
@@ -149,13 +149,13 @@ const [page] = await Promise.all([
console.log(await page.evaluate('location.href'));
```
-> **NOTE** Use [page.waitForLoadState()]() to wait until the page gets to a particular state (you should not need it in
-most cases).
+> **NOTE** Use [`method: Page.waitForLoadState`]() to wait until the page gets to a particular state (you should not
+need it in most cases).
## async method: BrowserContext.addCookies
Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
-obtained via [browserContext.cookies()]().
+obtained via [`method: BrowserContext.cookies`]().
```js
await browserContext.addCookies([cookieObject1, cookieObject2]);
@@ -196,8 +196,8 @@ await browserContext.addInitScript({
});
```
-> **NOTE** The order of evaluation of multiple scripts installed via [browserContext.addInitScript()]() and
-[page.addInitScript()]() is not defined.
+> **NOTE** The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`]() and
+[`method: Page.addInitScript`]() is not defined.
### param: BrowserContext.addInitScript.script
- `script` <[function]|[string]|[Object]>
@@ -209,7 +209,7 @@ Script to be evaluated in all pages in the browser context.
### param: BrowserContext.addInitScript.arg
- `arg` <[Serializable]>
-Optional argument to pass to `script` (only supported when passing a function).
+Optional argument to pass to [`param: script`]() (only supported when passing a function).
## method: BrowserContext.browser
- returns: <[null]|[Browser]>
@@ -258,14 +258,14 @@ Optional list of URLs.
## async method: BrowserContext.exposeBinding
-The method adds a function called `name` on the `window` object of every frame in every page in the context. When
-called, the function executes `playwrightBinding` and returns a [Promise] which resolves to the return value
-of `playwrightBinding`. If the `playwrightBinding` returns a [Promise], it will be awaited.
+The method adds a function called [`param: name`]() on the `window` object of every frame in every page in the context.
+When called, the function executes [`param: playwrightBinding`]() and returns a [Promise] which resolves to the return
+value of [`param: playwrightBinding`](). If the [`param: playwrightBinding`]() returns a [Promise], it will be awaited.
-The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext:
-BrowserContext, page: Page, frame: Frame }`.
+The first argument of the [`param: playwrightBinding`]() function contains information about the caller: `{
+browserContext: BrowserContext, page: Page, frame: Frame }`.
-See [page.exposeBinding()]() for page-only version.
+See [`method: Page.exposeBinding`]() for page-only version.
An example of exposing page URL to all frames in all pages in the context:
@@ -323,13 +323,13 @@ supported. When passing by value, multiple arguments are supported.
## async method: BrowserContext.exposeFunction
-The method adds a function called `name` on the `window` object of every frame in every page in the context. When
-called, the function executes `playwrightFunction` and returns a [Promise] which resolves to the return value
-of `playwrightFunction`.
+The method adds a function called [`param: name`]() on the `window` object of every frame in every page in the context.
+When called, the function executes [`param: playwrightFunction`]() and returns a [Promise] which resolves to the return
+value of [`param: playwrightFunction`]().
-If the `playwrightFunction` returns a [Promise], it will be awaited.
+If the [`param: playwrightFunction`]() returns a [Promise], it will be awaited.
-See [page.exposeFunction()]() for page-only version.
+See [`method: Page.exposeFunction`]() for page-only version.
An example of adding an `md5` function to all pages in the context:
@@ -404,7 +404,8 @@ Creates a new page in the browser context.
## method: BrowserContext.pages
- returns: <[Array]<[Page]>>
-Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can find them using [chromiumBrowserContext.backgroundPages()]().
+Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can
+find them using [`method: ChromiumBrowserContext.backgroundPages`]().
## async method: BrowserContext.route
@@ -431,7 +432,7 @@ await page.goto('https://example.com');
await browser.close();
```
-Page routes (set up with [page.route()]()) take precedence over browser context routes when request matches both
+Page routes (set up with [`method: Page.route`]()) take precedence over browser context routes when request matches both
handlers.
> **NOTE** Enabling routing disables http cache.
@@ -449,15 +450,15 @@ handler function to route the request.
## method: BrowserContext.setDefaultNavigationTimeout
This setting will change the default maximum navigation time for the following methods and related shortcuts:
-* [page.goBack()]()
-* [page.goForward()]()
-* [page.goto()]()
-* [page.reload()]()
-* [page.setContent()]()
-* [page.waitForNavigation()]()
+* [`method: Page.goBack`]()
+* [`method: Page.goForward`]()
+* [`method: Page.goto`]()
+* [`method: Page.reload`]()
+* [`method: Page.setContent`]()
+* [`method: Page.waitForNavigation`]()
-> **NOTE** [page.setDefaultNavigationTimeout()]() and [page.setDefaultTimeout()]() take priority over
-[browserContext.setDefaultNavigationTimeout()]().
+> **NOTE** [`method: Page.setDefaultNavigationTimeout`]() and [`method: Page.setDefaultTimeout`]() take priority over
+[`method: BrowserContext.setDefaultNavigationTimeout`]().
### param: BrowserContext.setDefaultNavigationTimeout.timeout
- `timeout` <[number]>
@@ -466,10 +467,10 @@ Maximum navigation time in milliseconds
## method: BrowserContext.setDefaultTimeout
-This setting will change the default maximum time for all the methods accepting `timeout` option.
+This setting will change the default maximum time for all the methods accepting [`param: timeout`]() option.
-> **NOTE** [page.setDefaultNavigationTimeout()](), [page.setDefaultTimeout()]() and
-[browserContext.setDefaultNavigationTimeout()]() take priority over [browserContext.setDefaultTimeout()]().
+> **NOTE** [`method: Page.setDefaultNavigationTimeout`](), [`method: Page.setDefaultTimeout`]() and [`method:
+BrowserContext.setDefaultNavigationTimeout`]() take priority over [`method: BrowserContext.setDefaultTimeout`]().
### param: BrowserContext.setDefaultTimeout.timeout
- `timeout` <[number]>
@@ -479,8 +480,8 @@ Maximum time in milliseconds
## async method: BrowserContext.setExtraHTTPHeaders
The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
-with page-specific extra HTTP headers set with [page.setExtraHTTPHeaders()](). If page overrides a particular header,
-page-specific header value will be used instead of the browser context header value.
+with page-specific extra HTTP headers set with [`method: Page.setExtraHTTPHeaders`](). If page overrides a particular
+header, page-specific header value will be used instead of the browser context header value.
> **NOTE** `browserContext.setExtraHTTPHeaders` does not guarantee the order of headers in the outgoing requests.
@@ -497,8 +498,8 @@ Sets the context's geolocation. Passing `null` or `undefined` emulates position
await browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});
```
-> **NOTE** Consider using [browserContext.grantPermissions()]() to grant permissions for the browser context pages to
-read its geolocation.
+> **NOTE** Consider using [`method: BrowserContext.grantPermissions`]() to grant permissions for the browser context
+pages to read its geolocation.
### param: BrowserContext.setGeolocation.geolocation
- `geolocation` <[null]|[Object]>
@@ -548,22 +549,25 @@ Returns storage state for this browser context, contains current cookies and loc
### option: BrowserContext.storageState.path
- `path` <[string]>
-The file path to save the storage state to. If `path` is a relative path, then it is resolved relative to [current working directory](https://nodejs.org/api/process.html#process_process_cwd). If no path is provided, storage state is still returned, but won't be saved to the disk.
+The file path to save the storage state to. If [`option: path`]() is a relative path, then it is resolved relative to
+[current working directory](https://nodejs.org/api/process.html#process_process_cwd). If no path is provided, storage
+state is still returned, but won't be saved to the disk.
## async method: BrowserContext.unroute
-Removes a route created with [browserContext.route()](). When `handler` is not specified, removes all routes for the
-`url`.
+Removes a route created with [`method: BrowserContext.route`](). When [`param: handler`]() is not specified, removes all
+routes for the [`param: url`]().
### param: BrowserContext.unroute.url
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
-A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with [browserContext.route()]().
+A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with [`method:
+BrowserContext.route`]().
### param: BrowserContext.unroute.handler
- `handler` <[function]\([Route], [Request]\)>
-Optional handler function used to register a routing with [browserContext.route()]().
+Optional handler function used to register a routing with [`method: BrowserContext.route`]().
## async method: BrowserContext.waitForEvent
- returns: <[Object]>
@@ -691,7 +695,7 @@ await new Promise((resolve, reject) => {
- <[Dialog]>
Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond
-to the dialog via [dialog.accept()]() or [dialog.dismiss()]() methods.
+to the dialog via [`method: Dialog.accept`]() or [`method: Dialog.dismiss`]() methods.
## event: Page.domcontentloaded
@@ -712,7 +716,7 @@ download is not performed and user has no access to the downloaded files.
- <[FileChooser]>
Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can
-respond to it via setting the input files using [fileChooser.setFiles()]() that can be uploaded after that.
+respond to it via setting the input files using [`method: FileChooser.setFiles`]() that can be uploaded after that.
```js
page.on('filechooser', async (fileChooser) => {
@@ -747,8 +751,8 @@ Emitted when an uncaught exception happens within the page.
## event: Page.popup
- <[Page]> Page corresponding to "popup" window
-Emitted when the page opens a new tab or window. This event is emitted in addition to the [browserContext.on('page')](),
-but only for popups relevant to this page.
+Emitted when the page opens a new tab or window. This event is emitted in addition to the [`event:
+BrowserContext.page`](), but only for popups relevant to this page.
The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
@@ -762,14 +766,14 @@ const [popup] = await Promise.all([
console.log(await popup.evaluate('location.href'));
```
-> **NOTE** Use [page.waitForLoadState()]() to wait until the page gets to a particular state (you should not need it in
-most cases).
+> **NOTE** Use [`method: Page.waitForLoadState`]() to wait until the page gets to a particular state (you should not
+need it in most cases).
## event: Page.request
- <[Request]>
Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see
-[page.route()]() or [browserContext.route()]().
+[`method: Page.route`]() or [`method: BrowserContext.route`]().
## event: Page.requestfailed
- <[Request]>
@@ -777,7 +781,7 @@ Emitted when a page issues a request. The [request] object is read-only. In orde
Emitted when a request fails, for example by timing out.
> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
-will complete with [page.on('requestfinished')]() event and not with [page.on('requestfailed')]().
+will complete with [`event: Page.requestfinished`]() event and not with [`event: Page.requestfailed`]().
## event: Page.requestfinished
- <[Request]>
@@ -808,7 +812,7 @@ page.
The method finds an element matching the specified selector within the page. If no elements match the selector, the
return value resolves to `null`.
-Shortcut for main frame's [frame.$()]().
+Shortcut for main frame's [`method: Frame.$`]().
### param: Page.$.selector = %%-query-selector-%%
@@ -818,7 +822,7 @@ Shortcut for main frame's [frame.$()]().
The method finds all elements matching the specified selector within the page. If no elements match the selector, the
return value resolves to `[]`.
-Shortcut for main frame's [frame.$$()]().
+Shortcut for main frame's [`method: Frame.$$`]().
### param: Page.$$.selector = %%-query-selector-%%
@@ -826,9 +830,11 @@ Shortcut for main frame's [frame.$$()]().
- returns: <[Serializable]>
The method finds an element matching the specified selector within the page and passes it as a first argument to
-`pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`.
+[`param: pageFunction`](). If no elements match the selector, the method throws an error. Returns the value of [`param:
+pageFunction`]().
-If `pageFunction` returns a [Promise], then `page.$eval` would wait for the promise to resolve and return its value.
+If [`param: pageFunction`]() returns a [Promise], then [`method: Page.$eval`]() would wait for the promise to resolve and return its
+value.
Examples:
@@ -838,7 +844,7 @@ const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
```
-Shortcut for main frame's [frame.$eval()]().
+Shortcut for main frame's [`method: Frame.$eval`]().
### param: Page.$eval.selector = %%-query-selector-%%
@@ -850,15 +856,16 @@ Function to be evaluated in browser context
### param: Page.$eval.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Page.$$eval
- returns: <[Serializable]>
The method finds all elements matching the specified selector within the page and passes an array of matched elements as
-a first argument to `pageFunction`. Returns the result of `pageFunction` invocation.
+a first argument to [`param: pageFunction`](). Returns the result of [`param: pageFunction`]() invocation.
-If `pageFunction` returns a [Promise], then `page.$$eval` would wait for the promise to resolve and return its value.
+If [`param: pageFunction`]() returns a [Promise], then [`method: Page.$$eval`]() would wait for the promise to resolve and return
+its value.
Examples:
@@ -876,7 +883,7 @@ Function to be evaluated in browser context
### param: Page.$$eval.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## namespace: Page.accessibility
- returns: <[Accessibility]>
@@ -901,8 +908,8 @@ const preloadFile = fs.readFileSync('./preload.js', 'utf8');
await page.addInitScript(preloadFile);
```
-> **NOTE** The order of evaluation of multiple scripts installed via [browserContext.addInitScript()]() and
-[page.addInitScript()]() is not defined.
+> **NOTE** The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`]() and
+[`method: Page.addInitScript`]() is not defined.
### param: Page.addInitScript.script
- `script` <[function]|[string]|[Object]>
@@ -914,7 +921,7 @@ Script to be evaluated in the page.
### param: Page.addInitScript.arg
- `arg` <[Serializable]>
-Optional argument to pass to `script` (only supported when passing a function).
+Optional argument to pass to [`param: script`]() (only supported when passing a function).
## async method: Page.addScriptTag
- returns: <[ElementHandle]>
@@ -922,7 +929,7 @@ Optional argument to pass to `script` (only supported when passing a function).
Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload
fires or when the script content was injected into frame.
-Shortcut for main frame's [frame.addScriptTag()]().
+Shortcut for main frame's [`method: Frame.addScriptTag`]().
### param: Page.addScriptTag.params
- `params` <[Object]>
@@ -937,7 +944,7 @@ Shortcut for main frame's [frame.addScriptTag()]().
Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
content. Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
-Shortcut for main frame's [frame.addStyleTag()]().
+Shortcut for main frame's [`method: Frame.addStyleTag`]().
### param: Page.addStyleTag.params
- `params` <[Object]>
@@ -951,19 +958,19 @@ Brings page to front (activates tab).
## async method: Page.check
-This method checks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
+This method checks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already checked, this method returns immediately.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use [page.mouse](#pagemouse) to click in the center of the element.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
1. Ensure that the element is now checked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.check()]().
+Shortcut for main frame's [`method: Frame.check`]().
### param: Page.check.selector = %%-input-selector-%%
@@ -975,17 +982,17 @@ Shortcut for main frame's [frame.check()]().
## async method: Page.click
-This method clicks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method clicks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.click()]().
+Shortcut for main frame's [`method: Frame.click`]().
### param: Page.click.selector = %%-input-selector-%%
@@ -1007,14 +1014,14 @@ Shortcut for main frame's [frame.click()]().
## async method: Page.close
-If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed.
-If `runBeforeUnload` is `true` the method will run unload handlers, but will **not** wait for the page
-to close.
+If [`option: runBeforeUnload`]() is `false`, does not run any unload handlers and waits for the page to be closed. If
+[`option: runBeforeUnload`]() is `true` the method will run unload handlers, but will **not** wait for the page to
+close.
By default, `page.close()` **does not** run `beforeunload` handlers.
-> **NOTE** if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned
-> and should be handled manually via [page.on('dialog')]() event.
+> **NOTE** if [`option: runBeforeUnload`]() is passed as true, a `beforeunload` dialog might be summoned
+> and should be handled manually via [`event: Page.dialog`]() event.
### option: Page.close.runBeforeUnload
- `runBeforeUnload` <[boolean]>
@@ -1040,19 +1047,19 @@ Browser-specific Coverage implementation, only available for Chromium atm. See
## async method: Page.dblclick
-This method double clicks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method double clicks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
+1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
-Shortcut for main frame's [frame.dblclick()]().
+Shortcut for main frame's [`method: Frame.dblclick`]().
### param: Page.dblclick.selector = %%-input-selector-%%
@@ -1080,10 +1087,11 @@ is dispatched. This is equivalend to calling
await page.dispatchEvent('button#submit', 'click');
```
-Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
-and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
+Under the hood, it creates an instance of an event based on the given [`param: type`](), initializes it with [`param:
+eventInit`]() properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
-Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
+Since [`param: eventInit`]() is event-specific, please refer to the events documentation for the lists of initial
+properties:
* [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
* [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
* [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
@@ -1153,7 +1161,7 @@ await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').ma
## async method: Page.evaluate
- returns: <[Serializable]>
-Returns the value of the `pageFunction` invacation.
+Returns the value of the [`param: pageFunction`]() invacation.
If the function passed to the `page.evaluate` returns a [Promise], then `page.evaluate` would wait for the promise to
resolve and return its value.
@@ -1162,7 +1170,7 @@ If the function passed to the `page.evaluate` returns a non-[Serializable] value
`undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`:
`-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
-Passing argument to `pageFunction`:
+Passing argument to [`param: pageFunction`]():
```js
const result = await page.evaluate(([x, y]) => {
@@ -1187,7 +1195,7 @@ const html = await page.evaluate(([body, suffix]) => body.innerHTML + suffix, [b
await bodyHandle.dispose();
```
-Shortcut for main frame's [frame.evaluate()]().
+Shortcut for main frame's [`method: Frame.evaluate`]().
### param: Page.evaluate.pageFunction
- `pageFunction` <[function]|[string]>
@@ -1197,12 +1205,12 @@ Function to be evaluated in the page context
### param: Page.evaluate.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Page.evaluateHandle
- returns: <[JSHandle]>
-Returns the value of the `pageFunction` invacation as in-page object (JSHandle).
+Returns the value of the [`param: pageFunction`]() invacation as in-page object (JSHandle).
The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page
object (JSHandle).
@@ -1233,18 +1241,18 @@ Function to be evaluated in the page context
### param: Page.evaluateHandle.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Page.exposeBinding
-The method adds a function called `name` on the `window` object of every frame in this page. When called, the function
-executes `playwrightBinding` and returns a [Promise] which resolves to the return value of
-`playwrightBinding`. If the `playwrightBinding` returns a [Promise], it will be awaited.
+The method adds a function called [`param: name`]() on the `window` object of every frame in this page. When called, the
+function executes [`param: playwrightBinding`]() and returns a [Promise] which resolves to the return value of [`param:
+playwrightBinding`](). If the [`param: playwrightBinding`]() returns a [Promise], it will be awaited.
-The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext:
-BrowserContext, page: Page, frame: Frame }`.
+The first argument of the [`param: playwrightBinding`]() function contains information about the caller: `{
+browserContext: BrowserContext, page: Page, frame: Frame }`.
-See [browserContext.exposeBinding()]() for the context-wide version.
+See [`method: BrowserContext.exposeBinding`]() for the context-wide version.
> **NOTE** Functions installed via `page.exposeBinding` survive navigations.
@@ -1304,13 +1312,13 @@ supported. When passing by value, multiple arguments are supported.
## async method: Page.exposeFunction
-The method adds a function called `name` on the `window` object of every frame in the page. When called, the function
-executes `playwrightFunction` and returns a [Promise] which resolves to the return value of
-`playwrightFunction`.
+The method adds a function called [`param: name`]() on the `window` object of every frame in the page. When called, the
+function executes [`param: playwrightFunction`]() and returns a [Promise] which resolves to the return value of [`param:
+playwrightFunction`]().
-If the `playwrightFunction` returns a [Promise], it will be awaited.
+If the [`param: playwrightFunction`]() returns a [Promise], it will be awaited.
-See [browserContext.exposeFunction()]() for context-wide exposed function.
+See [`method: BrowserContext.exposeFunction`]() for context-wide exposed function.
> **NOTE** Functions installed via `page.exposeFunction` survive navigations.
@@ -1378,14 +1386,14 @@ Callback function which will be called in Playwright's context.
## async method: Page.fill
-This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
-element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`,
-`<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to
-clear the input field.
+This method waits for an element matching [`param: selector`](), waits for [actionability](./actionability.md) checks,
+focuses the element, fills it and triggers an `input` event after filling. If the element matching [`param: selector`]()
+is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an
+empty string to clear the input field.
-To send fine-grained keyboard events, use [page.type()]().
+To send fine-grained keyboard events, use [`method: Page.type`]().
-Shortcut for main frame's [frame.fill()]()
+Shortcut for main frame's [`method: Frame.fill`]()
### param: Page.fill.selector = %%-input-selector-%%
@@ -1400,10 +1408,10 @@ Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
## async method: Page.focus
-This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
-waits until a matching element appears in the DOM.
+This method fetches an element with [`param: selector`]() and focuses it. If there's no element matching [`param:
+selector`](), the method waits until a matching element appears in the DOM.
-Shortcut for main frame's [frame.focus()]().
+Shortcut for main frame's [`method: Frame.focus`]().
### param: Page.focus.selector = %%-input-selector-%%
@@ -1481,20 +1489,20 @@ last redirect.
`page.goto` will throw an error if:
* there's an SSL error (e.g. in case of self-signed certificates).
* target URL is invalid.
-* the `timeout` is exceeded during navigation.
+* the [`option: timeout`]() is exceeded during navigation.
* the remote server does not respond or is unreachable.
* the main resource failed to load.
`page.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
-Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
-[response.status()]().
+Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling [`method:
+Response.status`]().
> **NOTE** `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
`about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
> **NOTE** Headless mode doesn't support navigation to a PDF document. See the [upstream
issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
-Shortcut for main frame's [frame.goto()]()
+Shortcut for main frame's [`method: Frame.goto`]()
### param: Page.goto.url
- `url` <[string]>
@@ -1508,22 +1516,22 @@ URL to navigate page to. The url should include scheme, e.g. `https://`.
### option: Page.goto.referer
- `referer` <[string]>
-Referer header value. If provided it will take preference over the referer header value set by
-[page.setExtraHTTPHeaders()]().
+Referer header value. If provided it will take preference over the referer header value set by [`method:
+Page.setExtraHTTPHeaders`]().
## async method: Page.hover
-This method hovers over an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method hovers over an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified `position`.
+1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified [`option: position`]().
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.hover()]().
+Shortcut for main frame's [`method: Frame.hover`]().
### param: Page.hover.selector = %%-input-selector-%%
@@ -1581,8 +1589,8 @@ Returns the PDF buffer.
> **NOTE** Generating a pdf is currently only supported in Chromium headless.
-`page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
-[page.emulateMedia()]() before calling `page.pdf()`:
+`page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call [`method:
+Page.emulateMedia`]() before calling `page.pdf()`:
> **NOTE** By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
[`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to
@@ -1594,7 +1602,8 @@ await page.emulateMedia({media: 'screen'});
await page.pdf({path: 'page.pdf'});
```
-The `width`, `height`, and `margin` options accept values labeled with units. Unlabeled values are treated as pixels.
+The [`option: width`](), [`option: height`](), and [`option: margin`]() options accept values labeled with units.
+Unlabeled values are treated as pixels.
A few examples:
* `page.pdf({width: 100})` - prints with width set to 100 pixels
@@ -1607,7 +1616,7 @@ All possible units are:
* `cm` - centimeter
* `mm` - millimeter
-The `format` options are:
+The [`option: format`]() options are:
* `Letter`: 8.5in x 11in
* `Legal`: 8.5in x 14in
* `Tabloid`: 11in x 17in
@@ -1620,15 +1629,15 @@ The `format` options are:
* `A5`: 5.83in x 8.27in
* `A6`: 4.13in x 5.83in
-> **NOTE** `headerTemplate` and `footerTemplate` markup have the following limitations:
+> **NOTE** [`option: headerTemplate`]() and [`option: footerTemplate`]() markup have the following limitations:
> 1. Script tags inside templates are not evaluated.
> 2. Page styles are not visible inside templates.
### option: Page.pdf.path
- `path` <[string]>
-The file path to save the PDF to. If `path` is a relative path, then it is resolved relative to the current working directory. If no path is provided, the PDF won't be saved to
-the disk.
+The file path to save the PDF to. If [`option: path`]() is a relative path, then it is resolved relative to the current
+working directory. If no path is provided, the PDF won't be saved to the disk.
### option: Page.pdf.scale
- `scale` <[number]>
@@ -1654,7 +1663,7 @@ into them:
### option: Page.pdf.footerTemplate
- `footerTemplate` <[string]>
-HTML template for the print footer. Should use the same format as the `headerTemplate`.
+HTML template for the print footer. Should use the same format as the [`option: headerTemplate`]().
### option: Page.pdf.printBackground
- `printBackground` <[boolean]>
@@ -1674,7 +1683,7 @@ Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, whic
### option: Page.pdf.format
- `format` <[string]>
-Paper format. If set, takes priority over `width` or `height` options. Defaults to 'Letter'.
+Paper format. If set, takes priority over [`option: width`]() or [`option: height`]() options. Defaults to 'Letter'.
### option: Page.pdf.width
- `width` <[string]|[number]>
@@ -1698,15 +1707,16 @@ Paper margins, defaults to none.
### option: Page.pdf.preferCSSPageSize
- `preferCSSPageSize` <[boolean]>
-Give any CSS `@page` size declared in the page priority over what is declared in `width` and `height` or `format`
-options. Defaults to `false`, which will scale the content to fit the paper size.
+Give any CSS `@page` size declared in the page priority over what is declared in [`option: width`]() and [`option:
+height`]() or [`option: format`]() options. Defaults to `false`, which will scale the content to fit the paper size.
## async method: Page.press
-Focuses the element, and then uses [keyboard.down()]() and [keyboard.up()]().
+Focuses the element, and then uses [`method: Keyboard.down`]() and [`method: Keyboard.up`]().
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
+[`param: key`]() can specify the intended
+[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
+generate the text for. A superset of the [`param: key`]() values can be found
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
@@ -1714,10 +1724,10 @@ value or a single character to generate the text for. A superset of the `key` va
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
-Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
+Holding down `Shift` will type the text that corresponds to the [`param: key`]() in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If [`param: key`]() is a single character, it is case-sensitive, so the values `a` and `A` will generate different
+respective texts.
Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
modifier, modifier is pressed and being held while the subsequent key is being pressed.
@@ -1786,8 +1796,8 @@ await page.goto('https://example.com');
await browser.close();
```
-Page routes take precedence over browser context routes (set up with [browserContext.route()]()) when request matches
-both handlers.
+Page routes take precedence over browser context routes (set up with [`method: BrowserContext.route`]()) when request
+matches both handlers.
> **NOTE** Enabling routing disables http cache.
@@ -1812,9 +1822,9 @@ discussion.
### option: Page.screenshot.path
- `path` <[string]>
-The file path to save the image to. The screenshot type will be inferred from file extension. If `path` is a relative
-path, then it is resolved relative to the current working directory. If no path is provided, the image won't be saved to
-the disk.
+The file path to save the image to. The screenshot type will be inferred from file extension. If [`option: path`]() is a
+relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be
+saved to the disk.
### option: Page.screenshot.type
- `type` <"png"|"jpeg">
@@ -1855,7 +1865,7 @@ Defaults to `false`.
Returns the array of option values that have been successfully selected.
Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
-matching `selector`, the method throws an error.
+matching [`param: selector`](), the method throws an error.
```js
// single selection matching the value
@@ -1869,7 +1879,7 @@ page.selectOption('select#colors', ['red', 'green', 'blue']);
```
-Shortcut for main frame's [frame.selectOption()]()
+Shortcut for main frame's [`method: Frame.selectOption`]()
### param: Page.selectOption.selector = %%-input-selector-%%
@@ -1901,15 +1911,15 @@ HTML markup to assign to the page.
## method: Page.setDefaultNavigationTimeout
This setting will change the default maximum navigation time for the following methods and related shortcuts:
-* [page.goBack()]()
-* [page.goForward()]()
-* [page.goto()]()
-* [page.reload()]()
-* [page.setContent()]()
-* [page.waitForNavigation()]()
+* [`method: Page.goBack`]()
+* [`method: Page.goForward`]()
+* [`method: Page.goto`]()
+* [`method: Page.reload`]()
+* [`method: Page.setContent`]()
+* [`method: Page.waitForNavigation`]()
-> **NOTE** [page.setDefaultNavigationTimeout()]() takes priority over [page.setDefaultTimeout()](),
-[browserContext.setDefaultTimeout()]() and [browserContext.setDefaultNavigationTimeout()]().
+> **NOTE** [`method: Page.setDefaultNavigationTimeout`]() takes priority over [`method: Page.setDefaultTimeout`](),
+[`method: BrowserContext.setDefaultTimeout`]() and [`method: BrowserContext.setDefaultNavigationTimeout`]().
### param: Page.setDefaultNavigationTimeout.timeout
- `timeout` <[number]>
@@ -1918,9 +1928,9 @@ Maximum navigation time in milliseconds
## method: Page.setDefaultTimeout
-This setting will change the default maximum time for all the methods accepting `timeout` option.
+This setting will change the default maximum time for all the methods accepting [`param: timeout`]() option.
-> **NOTE** [page.setDefaultNavigationTimeout()]() takes priority over [page.setDefaultTimeout()]().
+> **NOTE** [`method: Page.setDefaultNavigationTimeout`]() takes priority over [`method: Page.setDefaultTimeout`]().
### param: Page.setDefaultTimeout.timeout
- `timeout` <[number]>
@@ -1940,12 +1950,11 @@ An object containing additional HTTP headers to be sent with every request. All
## async method: Page.setInputFiles
-This method expects `selector` to point to an [input
+This method expects [`param: selector`]() to point to an [input
element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
-are resolved relative to the the current working directory. For
-empty array, clears the selected files.
+are resolved relative to the the current working directory. For empty array, clears the selected files.
### param: Page.setInputFiles.selector = %%-input-selector-%%
@@ -1957,8 +1966,8 @@ empty array, clears the selected files.
## async method: Page.setViewportSize
-In the case of multiple pages in a single browser, each page can have its own viewport size. However,
-[browser.newContext()]() allows to set viewport size (and more) for all pages in the context at once.
+In the case of multiple pages in a single browser, each page can have its own viewport size. However, [`method:
+Browser.newContext`]() allows to set viewport size (and more) for all pages in the context at once.
`page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the
viewport size before navigating to the page.
@@ -1979,19 +1988,19 @@ await page.goto('https://example.com');
## async method: Page.tap
-This method taps an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method taps an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.touchscreen](#pagetouchscreen#pagetouchscreen) to tap the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Use [page.touchscreen](#pagetouchscreen#pagetouchscreen) to tap the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `page.tap()` requires that the `hasTouch` option of the browser context be set to true.
-Shortcut for main frame's [frame.tap()]().
+Shortcut for main frame's [`method: Frame.tap`]().
### param: Page.tap.selector = %%-input-selector-%%
@@ -2017,7 +2026,7 @@ Returns `element.textContent`.
## async method: Page.title
- returns: <[string]>
-Returns the page's title. Shortcut for main frame's [frame.title()]().
+Returns the page's title. Shortcut for main frame's [`method: Frame.title`]().
## namespace: Page.touchscreen
- returns: <[Touchscreen]>
@@ -2025,16 +2034,16 @@ Returns the page's title. Shortcut for main frame's [frame.title()]().
## async method: Page.type
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send
-fine-grained keyboard events. To fill values in form fields, use [page.fill()]().
+fine-grained keyboard events. To fill values in form fields, use [`method: Page.fill`]().
-To press a special key, like `Control` or `ArrowDown`, use [keyboard.press()]().
+To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`]().
```js
await page.type('#mytextarea', 'Hello'); // Types instantly
await page.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
```
-Shortcut for main frame's [frame.type()]().
+Shortcut for main frame's [`method: Frame.type`]().
### param: Page.type.selector = %%-input-selector-%%
@@ -2054,19 +2063,19 @@ Time to wait between key presses in milliseconds. Defaults to 0.
## async method: Page.uncheck
-This method unchecks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
+This method unchecks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already unchecked, this method returns immediately.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use [page.mouse](#pagemouse) to click in the center of the element.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
1. Ensure that the element is now unchecked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.uncheck()]().
+Shortcut for main frame's [`method: Frame.uncheck`]().
### param: Page.uncheck.selector = %%-input-selector-%%
@@ -2078,7 +2087,8 @@ Shortcut for main frame's [frame.uncheck()]().
## async method: Page.unroute
-Removes a route created with [page.route()](). When `handler` is not specified, removes all routes for the `url`.
+Removes a route created with [`method: Page.route`](). When [`param: handler`]() is not specified, removes all routes
+for the [`param: url`]().
### param: Page.unroute.url
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
@@ -2093,7 +2103,7 @@ Optional handler function to route the request.
## method: Page.url
- returns: <[string]>
-Shortcut for main frame's [frame.url()]().
+Shortcut for main frame's [`method: Frame.url`]().
## method: Page.video
- returns: <[null]|[Video]>
@@ -2128,7 +2138,7 @@ Either a predicate that receives an event or an options object. Optional.
## async method: Page.waitForFunction
- returns: <[JSHandle]>
-Returns when the `pageFunction` returns a truthy value. It resolves to a JSHandle of the truthy value.
+Returns when the [`param: pageFunction`]() returns a truthy value. It resolves to a JSHandle of the truthy value.
The `waitForFunction` can be used to observe viewport size change:
@@ -2152,7 +2162,7 @@ const selector = '.foo';
await page.waitForFunction(selector => !!document.querySelector(selector), selector);
```
-Shortcut for main frame's [frame.waitForFunction()]().
+Shortcut for main frame's [`method: Frame.waitForFunction`]().
### param: Page.waitForFunction.pageFunction
- `pageFunction` <[function]|[string]>
@@ -2162,13 +2172,14 @@ Function to be evaluated in browser context
### param: Page.waitForFunction.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
### option: Page.waitForFunction.polling
- `polling` <[number]|"raf">
-If `polling` is `'raf'`, then `pageFunction` is constantly executed in `requestAnimationFrame` callback. If `polling` is
-a number, then it is treated as an interval in milliseconds at which the function would be executed. Defaults to `raf`.
+If [`option: polling`]() is `'raf'`, then [`param: pageFunction`]() is constantly executed in `requestAnimationFrame`
+callback. If [`option: polling`]() is a number, then it is treated as an interval in milliseconds at which the function
+would be executed. Defaults to `raf`.
### option: Page.waitForFunction.timeout = %%-wait-for-timeout-%%
@@ -2193,7 +2204,7 @@ await popup.waitForLoadState('domcontentloaded'); // The promise resolves after
console.log(await popup.title()); // Popup is ready to use.
```
-Shortcut for main frame's [frame.waitForLoadState()]().
+Shortcut for main frame's [`method: Frame.waitForLoadState`]().
### param: Page.waitForLoadState.state
- `state` <"load"|"domcontentloaded"|"networkidle">
@@ -2227,7 +2238,7 @@ const [response] = await Promise.all([
**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
considered a navigation.
-Shortcut for main frame's [frame.waitForNavigation()]().
+Shortcut for main frame's [`method: Frame.waitForNavigation`]().
### option: Page.waitForNavigation.timeout = %%-navigation-timeout-%%
@@ -2262,7 +2273,7 @@ Request URL string, regex or predicate receiving [Request] object.
- `timeout` <[number]>
Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be
-changed by using the [page.setDefaultTimeout()]() method.
+changed by using the [`method: Page.setDefaultTimeout`]() method.
## async method: Page.waitForResponse
- returns: <[Response]>
@@ -2284,17 +2295,18 @@ Request URL string, regex or predicate receiving [Response] object.
- `timeout` <[number]>
Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be
-changed by using the [browserContext.setDefaultTimeout()]() or [page.setDefaultTimeout()]() methods.
+changed by using the [`method: BrowserContext.setDefaultTimeout`]() or [`method: Page.setDefaultTimeout`]() methods.
## async method: Page.waitForSelector
- returns: <[null]|[ElementHandle]>
-Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
-`detached`.
+Returns when element specified by selector satisfies [`option: state`]() option. Returns `null` if waiting for `hidden`
+or `detached`.
-Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
-the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
-selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
+Wait for the [`param: selector`]() to satisfy [`option: state`]() option (either appear/disappear from dom, or become
+visible/hidden). If at the moment of calling the method [`param: selector`]() already satisfies the condition, the
+method will return immediately. If the selector doesn't satisfy the condition for the [`option: timeout`]()
+milliseconds, the function will throw.
This method works across navigations:
@@ -2323,7 +2335,7 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
## async method: Page.waitForTimeout
-Waits for the given `timeout` in milliseconds.
+Waits for the given [`param: timeout`]() in milliseconds.
Note that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be
flaky. Use signals such as network events, selectors becoming visible and others instead.
@@ -2333,7 +2345,7 @@ flaky. Use signals such as network events, selectors becoming visible and others
await page.waitForTimeout(1000);
```
-Shortcut for main frame's [frame.waitForTimeout()]().
+Shortcut for main frame's [`method: Frame.waitForTimeout`]().
### param: Page.waitForTimeout.timeout
- `timeout` <[number]>
@@ -2343,19 +2355,20 @@ A timeout to wait for
## method: Page.workers
- returns: <[Array]<[Worker]>>
-This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) associated with the page.
+This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
+associated with the page.
> **NOTE** This does not contain ServiceWorkers
# class: Frame
-At every point of time, page exposes its current frame tree via the [page.mainFrame()]() and [frame.childFrames()]()
-methods.
+At every point of time, page exposes its current frame tree via the [`method: Page.mainFrame`]() and [`method:
+Frame.childFrames`]() methods.
[Frame] object's lifecycle is controlled by three events, dispatched on the page object:
-- [page.on('frameattached')]() - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
-- [page.on('framenavigated')]() - fired when the frame commits navigation to a different URL.
-- [page.on('framedetached')]() - fired when the frame gets detached from the page. A Frame can be detached from the page only once.
+- [`event: Page.frameattached`]() - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
+- [`event: Page.framenavigated`]() - fired when the frame commits navigation to a different URL.
+- [`event: Page.framedetached`]() - fired when the frame gets detached from the page. A Frame can be detached from the page only once.
An example of dumping frame tree:
@@ -2412,13 +2425,14 @@ selectors](#working-with-selectors) for more details. If no elements match the s
## async method: Frame.$eval
- returns: <[Serializable]>
-Returns the return value of `pageFunction`
+Returns the return value of [`param: pageFunction`]()
The method finds an element matching the specified selector within the frame and passes it as a first argument to
-`pageFunction`. See [Working with selectors](#working-with-selectors) for more details. If no elements match the
-selector, the method throws an error.
+[`param: pageFunction`](). See [Working with selectors](#working-with-selectors) for more details. If no elements match
+the selector, the method throws an error.
-If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
+If [`param: pageFunction`]() returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return
+its value.
Examples:
@@ -2438,17 +2452,19 @@ Function to be evaluated in browser context
### param: Frame.$eval.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Frame.$$eval
- returns: <[Serializable]>
-Returns the return value of `pageFunction`
+Returns the return value of [`param: pageFunction`]()
The method finds all elements matching the specified selector within the frame and passes an array of matched elements
-as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details.
+as a first argument to [`param: pageFunction`](). See [Working with selectors](#working-with-selectors) for more
+details.
-If `pageFunction` returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return its value.
+If [`param: pageFunction`]() returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return
+its value.
Examples:
@@ -2466,7 +2482,7 @@ Function to be evaluated in browser context
### param: Frame.$$eval.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Frame.addScriptTag
- returns: <[ElementHandle]>
@@ -2498,17 +2514,17 @@ content.
## async method: Frame.check
-This method checks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
+This method checks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already checked, this method returns immediately.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use [page.mouse](#pagemouse) to click in the center of the element.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
1. Ensure that the element is now checked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### param: Frame.check.selector = %%-input-selector-%%
@@ -2523,15 +2539,15 @@ Passing zero timeout disables this.
## async method: Frame.click
-This method clicks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method clicks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### param: Frame.click.selector = %%-input-selector-%%
@@ -2558,15 +2574,15 @@ Gets the full HTML contents of the frame, including the doctype.
## async method: Frame.dblclick
-This method double clicks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method double clicks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
+1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
@@ -2596,10 +2612,11 @@ is dispatched. This is equivalend to calling
await frame.dispatchEvent('button#submit', 'click');
```
-Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
-and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
+Under the hood, it creates an instance of an event based on the given [`param: type`](), initializes it with [`param:
+eventInit`]() properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
-Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
+Since [`param: eventInit`]() is event-specific, please refer to the events documentation for the lists of initial
+properties:
* [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
* [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
* [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
@@ -2633,7 +2650,7 @@ Optional event-specific initialization properties.
## async method: Frame.evaluate
- returns: <[Serializable]>
-Returns the return value of `pageFunction`
+Returns the return value of [`param: pageFunction`]()
If the function passed to the `frame.evaluate` returns a [Promise], then `frame.evaluate` would wait for the promise to
resolve and return its value.
@@ -2671,12 +2688,12 @@ Function to be evaluated in browser context
### param: Frame.evaluate.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Frame.evaluateHandle
- returns: <[JSHandle]>
-Returns the return value of `pageFunction` as in-page object (JSHandle).
+Returns the return value of [`param: pageFunction`]() as in-page object (JSHandle).
The only difference between `frame.evaluate` and `frame.evaluateHandle` is that `frame.evaluateHandle` returns in-page
object (JSHandle).
@@ -2712,16 +2729,16 @@ Function to be evaluated in the page context
### param: Frame.evaluateHandle.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Frame.fill
-This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
-element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`,
-`<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to
-clear the input field.
+This method waits for an element matching [`param: selector`](), waits for [actionability](./actionability.md) checks,
+focuses the element, fills it and triggers an `input` event after filling. If the element matching [`param: selector`]()
+is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an
+empty string to clear the input field.
-To send fine-grained keyboard events, use [frame.type()]().
+To send fine-grained keyboard events, use [`method: Frame.type`]().
### param: Frame.fill.selector = %%-input-selector-%%
@@ -2736,8 +2753,8 @@ Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
## async method: Frame.focus
-This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
-waits until a matching element appears in the DOM.
+This method fetches an element with [`param: selector`]() and focuses it. If there's no element matching [`param:
+selector`](), the method waits until a matching element appears in the DOM.
### param: Frame.focus.selector = %%-input-selector-%%
@@ -2748,7 +2765,8 @@ waits until a matching element appears in the DOM.
Returns the `frame` or `iframe` element handle which corresponds to this frame.
-This is an inverse of [elementHandle.contentFrame()](). Note that returned handle actually belongs to the parent frame.
+This is an inverse of [`method: ElementHandle.contentFrame`](). Note that returned handle actually belongs to the parent
+frame.
This method throws an error if the frame has been detached before `frameElement()` returns.
@@ -2781,13 +2799,13 @@ last redirect.
`frame.goto` will throw an error if:
* there's an SSL error (e.g. in case of self-signed certificates).
* target URL is invalid.
-* the `timeout` is exceeded during navigation.
+* the [`option: timeout`]() is exceeded during navigation.
* the remote server does not respond or is unreachable.
* the main resource failed to load.
`frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404
-"Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
-[response.status()]().
+"Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling [`method:
+Response.status`]().
> **NOTE** `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation
to `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
@@ -2806,20 +2824,20 @@ URL to navigate frame to. The url should include scheme, e.g. `https://`.
### option: Frame.goto.referer
- `referer` <[string]>
-Referer header value. If provided it will take preference over the referer header value set by
-[page.setExtraHTTPHeaders()]().
+Referer header value. If provided it will take preference over the referer header value set by [`method:
+Page.setExtraHTTPHeaders`]().
## async method: Frame.hover
-This method hovers over an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method hovers over an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified `position`.
+1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified [`option: position`]().
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### param: Frame.hover.selector = %%-input-selector-%%
@@ -2876,8 +2894,9 @@ Parent frame, if any. Detached frames and main frames return `null`.
## async method: Frame.press
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
+[`param: key`]() can specify the intended
+[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
+generate the text for. A superset of the [`param: key`]() values can be found
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
@@ -2885,10 +2904,10 @@ value or a single character to generate the text for. A superset of the `key` va
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
-Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
+Holding down `Shift` will type the text that corresponds to the [`param: key`]() in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If [`param: key`]() is a single character, it is case-sensitive, so the values `a` and `A` will generate different
+respective texts.
Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
modifier, modifier is pressed and being held while the subsequent key is being pressed.
@@ -2915,7 +2934,7 @@ Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
Returns the array of option values that have been successfully selected.
Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
-matching `selector`, the method throws an error.
+matching [`param: selector`](), the method throws an error.
```js
// single selection matching the value
@@ -2957,12 +2976,11 @@ HTML markup to assign to the page.
## async method: Frame.setInputFiles
-This method expects `selector` to point to an [input
+This method expects [`param: selector`]() to point to an [input
element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
-are resolved relative to the the current working directory. For
-empty array, clears the selected files.
+are resolved relative to the the current working directory. For empty array, clears the selected files.
### param: Frame.setInputFiles.selector = %%-input-selector-%%
@@ -2974,15 +2992,15 @@ empty array, clears the selected files.
## async method: Frame.tap
-This method taps an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+This method taps an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
-1. Use [page.touchscreen](#pagetouchscreen#pagetouchscreen) to tap the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Use [page.touchscreen](#pagetouchscreen#pagetouchscreen) to tap the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
@@ -3015,9 +3033,9 @@ Returns the page title.
## async method: Frame.type
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
-send fine-grained keyboard events. To fill values in form fields, use [frame.fill()]().
+send fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`]().
-To press a special key, like `Control` or `ArrowDown`, use [keyboard.press()]().
+To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`]().
```js
await frame.type('#mytextarea', 'Hello'); // Types instantly
@@ -3042,17 +3060,17 @@ Time to wait between key presses in milliseconds. Defaults to 0.
## async method: Frame.uncheck
-This method checks an element matching `selector` by performing the following steps:
-1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
+This method checks an element matching [`param: selector`]() by performing the following steps:
+1. Find an element match matching [`param: selector`](). If there is none, wait until a matching element is attached to the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already unchecked, this method returns immediately.
-1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
+1. Wait for [actionability](./actionability.md) checks on the matched element, unless [`option: force`]() option is set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use [page.mouse](#pagemouse) to click in the center of the element.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
1. Ensure that the element is now unchecked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### param: Frame.uncheck.selector = %%-input-selector-%%
@@ -3070,7 +3088,7 @@ Returns frame's url.
## async method: Frame.waitForFunction
- returns: <[JSHandle]>
-Returns when the `pageFunction` returns a truthy value, returns that value.
+Returns when the [`param: pageFunction`]() returns a truthy value, returns that value.
The `waitForFunction` can be used to observe viewport size change:
@@ -3102,13 +3120,14 @@ Function to be evaluated in browser context
### param: Frame.waitForFunction.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
### option: Frame.waitForFunction.polling
- `polling` <[number]|"raf">
-If `polling` is `'raf'`, then `pageFunction` is constantly executed in `requestAnimationFrame` callback. If `polling` is
-a number, then it is treated as an interval in milliseconds at which the function would be executed. Defaults to `raf`.
+If [`option: polling`]() is `'raf'`, then [`param: pageFunction`]() is constantly executed in `requestAnimationFrame`
+callback. If [`option: polling`]() is a number, then it is treated as an interval in milliseconds at which the function
+would be executed. Defaults to `raf`.
### option: Frame.waitForFunction.timeout = %%-wait-for-timeout-%%
@@ -3142,8 +3161,8 @@ Returns the main resource response. In case of multiple redirects, the navigatio
last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
resolve with `null`.
-This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause the
-frame to navigate. Consider this example:
+This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
+the frame to navigate. Consider this example:
```js
const [response] = await Promise.all([
@@ -3167,12 +3186,13 @@ URL string, URL regex pattern or predicate receiving [URL] to match while waitin
## async method: Frame.waitForSelector
- returns: <[null]|[ElementHandle]>
-Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
-`detached`.
+Returns when element specified by selector satisfies [`option: state`]() option. Returns `null` if waiting for `hidden`
+or `detached`.
-Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
-the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
-selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
+Wait for the [`param: selector`]() to satisfy [`option: state`]() option (either appear/disappear from dom, or become
+visible/hidden). If at the moment of calling the method [`param: selector`]() already satisfies the condition, the
+method will return immediately. If the selector doesn't satisfy the condition for the [`option: timeout`]()
+milliseconds, the function will throw.
This method works across navigations:
@@ -3201,7 +3221,7 @@ const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
## async method: Frame.waitForTimeout
-Waits for the given `timeout` in milliseconds.
+Waits for the given [`param: timeout`]() in milliseconds.
Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
be flaky. Use signals such as network events, selectors becoming visible and others instead.
@@ -3214,7 +3234,7 @@ A timeout to wait for
# class: ElementHandle
* extends: [JSHandle]
-ElementHandle represents an in-page DOM element. ElementHandles can be created with the [page.$()]() method.
+ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`method: Page.$`]() method.
```js
const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
@@ -3229,10 +3249,10 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-ElementHandle prevents DOM element from garbage collection unless the handle is disposed with [jsHandle.dispose()]().
-ElementHandles are auto-disposed when their origin frame gets navigated.
+ElementHandle prevents DOM element from garbage collection unless the handle is disposed with [`method:
+JSHandle.dispose`](). ElementHandles are auto-disposed when their origin frame gets navigated.
-ElementHandle instances can be used as an argument in [page.$eval()]() and [page.evaluate()]() methods.
+ElementHandle instances can be used as an argument in [`method: Page.$eval`]() and [`method: Page.evaluate`]() methods.
<!-- GEN:toc -->
<!-- GEN:stop -->
@@ -3259,13 +3279,14 @@ selectors](#working-with-selectors) for more details. If no elements match the s
## async method: ElementHandle.$eval
- returns: <[Serializable]>
-Returns the return value of `pageFunction`
+Returns the return value of [`param: pageFunction`]()
The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
-argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details. If no elements match
-the selector, the method throws an error.
+argument to [`param: pageFunction`](). See [Working with selectors](#working-with-selectors) for more details. If no
+elements match the selector, the method throws an error.
-If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
+If [`param: pageFunction`]() returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return
+its value.
Examples:
@@ -3285,18 +3306,19 @@ Function to be evaluated in browser context
### param: ElementHandle.$eval.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: ElementHandle.$$eval
- returns: <[Serializable]>
-Returns the return value of `pageFunction`
+Returns the return value of [`param: pageFunction`]()
The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
-matched elements as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more
-details.
+matched elements as a first argument to [`param: pageFunction`](). See [Working with selectors](#working-with-selectors)
+for more details.
-If `pageFunction` returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return its value.
+If [`param: pageFunction`]() returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return
+its value.
Examples:
@@ -3322,7 +3344,7 @@ Function to be evaluated in browser context
### param: ElementHandle.$$eval.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: ElementHandle.boundingBox
- returns: <[null]|[Object]>
@@ -3353,16 +3375,16 @@ await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
This method checks the element by performing the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already checked, this method returns immediately.
-1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
+1. Wait for [actionability](./actionability.md) checks on the element, unless [`option: force`]() option is set.
1. Scroll the element into view if needed.
1. Use [page.mouse](#pagemouse) to click in the center of the element.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
1. Ensure that the element is now checked. If not, this method rejects.
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.check.force = %%-input-force-%%
@@ -3373,15 +3395,15 @@ Passing zero timeout disables this.
## async method: ElementHandle.click
This method clicks the element by performing the following steps:
-1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
+1. Wait for [actionability](./actionability.md) checks on the element, unless [`option: force`]() option is set.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.click.button = %%-input-button-%%
@@ -3407,15 +3429,15 @@ Returns the content frame for element handles referencing iframe nodes, or `null
## async method: ElementHandle.dblclick
This method double clicks the element by performing the following steps:
-1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
+1. Wait for [actionability](./actionability.md) checks on the element, unless [`option: force`]() option is set.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
+1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
@@ -3443,10 +3465,11 @@ is dispatched. This is equivalend to calling
await elementHandle.dispatchEvent('click');
```
-Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
-and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
+Under the hood, it creates an instance of an event based on the given [`param: type`](), initializes it with [`param:
+eventInit`]() properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
-Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
+Since [`param: eventInit`]() is event-specific, please refer to the events documentation for the lists of initial
+properties:
* [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
* [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
* [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
@@ -3505,15 +3528,15 @@ Attribute name to get the value for.
## async method: ElementHandle.hover
This method hovers over the element by performing the following steps:
-1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
+1. Wait for [actionability](./actionability.md) checks on the element, unless [`option: force`]() option is set.
1. Scroll the element into view if needed.
-1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified `position`.
+1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified [`option: position`]().
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.hover.position = %%-input-position-%%
@@ -3540,10 +3563,11 @@ Returns the frame containing the given element.
## async method: ElementHandle.press
-Focuses the element, and then uses [keyboard.down()]() and [keyboard.up()]().
+Focuses the element, and then uses [`method: Keyboard.down`]() and [`method: Keyboard.up`]().
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
+[`param: key`]() can specify the intended
+[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
+generate the text for. A superset of the [`param: key`]() values can be found
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
@@ -3551,10 +3575,10 @@ value or a single character to generate the text for. A superset of the `key` va
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
-Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
+Holding down `Shift` will type the text that corresponds to the [`param: key`]() in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If [`param: key`]() is a single character, it is case-sensitive, so the values `a` and `A` will generate different
+respective texts.
Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
modifier, modifier is pressed and being held while the subsequent key is being pressed.
@@ -3584,9 +3608,9 @@ screenshot. If the element is detached from DOM, the method throws an error.
### option: ElementHandle.screenshot.path
- `path` <[string]>
-The file path to save the image to. The screenshot type will be inferred from file extension. If `path` is a relative
-path, then it is resolved relative to the current working directory. If no path is provided, the image won't be saved
-to the disk.
+The file path to save the image to. The screenshot type will be inferred from file extension. If [`option: path`]() is a
+relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be
+saved to the disk.
### option: ElementHandle.screenshot.type
- `type` <"png"|"jpeg">
@@ -3666,8 +3690,7 @@ This method expects `elementHandle` to point to an [input
element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
-are resolved relative to the the current working directory. For
-empty array, clears the selected files.
+are resolved relative to the the current working directory. For empty array, clears the selected files.
### param: ElementHandle.setInputFiles.files = %%-input-files-%%
@@ -3678,15 +3701,15 @@ empty array, clears the selected files.
## async method: ElementHandle.tap
This method taps the element by performing the following steps:
-1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
+1. Wait for [actionability](./actionability.md) checks on the element, unless [`option: force`]() option is set.
1. Scroll the element into view if needed.
-1. Use [page.touchscreen](#pagetouchscreen) to tap in the center of the element, or the specified `position`.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Use [page.touchscreen](#pagetouchscreen) to tap in the center of the element, or the specified [`option: position`]().
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
@@ -3712,7 +3735,7 @@ Returns the `node.textContent`.
Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
-To press a special key, like `Control` or `ArrowDown`, use [elementHandle.press()]().
+To press a special key, like `Control` or `ArrowDown`, use [`method: ElementHandle.press`]().
```js
await elementHandle.type('Hello'); // Types instantly
@@ -3745,16 +3768,16 @@ Time to wait between key presses in milliseconds. Defaults to 0.
This method checks the element by performing the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already unchecked, this method returns immediately.
-1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
+1. Wait for [actionability](./actionability.md) checks on the element, unless [`option: force`]() option is set.
1. Scroll the element into view if needed.
1. Use [page.mouse](#pagemouse) to click in the center of the element.
-1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
+1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`]() option is set.
1. Ensure that the element is now unchecked. If not, this method rejects.
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified [`option: timeout`](), this method rejects with a
+[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.uncheck.force = %%-input-force-%%
@@ -3764,17 +3787,17 @@ Passing zero timeout disables this.
## async method: ElementHandle.waitForElementState
-Returns the element satisfies the `state`.
+Returns the element satisfies the [`param: state`]().
-Depending on the `state` parameter, this method waits for one of the [actionability](./actionability.md) checks to pass.
-This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
+Depending on the [`param: state`]() parameter, this method waits for one of the [actionability](./actionability.md)
+checks to pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
* `"visible"` Wait until the element is [visible](./actionability.md#visible).
* `"hidden"` Wait until the element is [not visible](./actionability.md#visible) or [not attached](./actionability.md#attached). Note that waiting for hidden does not throw when the element detaches.
* `"stable"` Wait until the element is both [visible](./actionability.md#visible) and [stable](./actionability.md#stable).
* `"enabled"` Wait until the element is [enabled](./actionability.md#enabled).
* `"disabled"` Wait until the element is [not enabled](./actionability.md#enabled).
-If the element does not satisfy the condition for the `timeout` milliseconds, this method will throw.
+If the element does not satisfy the condition for the [`option: timeout`]() milliseconds, this method will throw.
### param: ElementHandle.waitForElementState.state
- `state` <"visible"|"hidden"|"stable"|"enabled"|"disabled">
@@ -3786,13 +3809,13 @@ A state to wait for, see below for more details.
## async method: ElementHandle.waitForSelector
- returns: <[null]|[ElementHandle]>
-Returns element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
+Returns element specified by selector satisfies [`option: state`]() option. Returns `null` if waiting for `hidden` or
`detached`.
-Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or
-become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
-will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will
-throw.
+Wait for the [`param: selector`]() relative to the element handle to satisfy [`option: state`]() option (either
+appear/disappear from dom, or become visible/hidden). If at the moment of calling the method [`param: selector`]()
+already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for
+the [`option: timeout`]() milliseconds, the function will throw.
```js
await page.setContent(`<div><span></span></div>`);
@@ -3801,7 +3824,7 @@ const div = await page.$('div');
const span = await div.waitForSelector('span', { state: 'attached' });
```
-> **NOTE** This method does not work across navigations, use [page.waitForSelector()]() instead.
+> **NOTE** This method does not work across navigations, use [`method: Page.waitForSelector`]() instead.
### param: ElementHandle.waitForSelector.selector = %%-query-selector-%%
@@ -3811,19 +3834,20 @@ const span = await div.waitForSelector('span', { state: 'attached' });
# class: JSHandle
-JSHandle represents an in-page JavaScript object. JSHandles can be created with the [page.evaluateHandle()]() method.
+JSHandle represents an in-page JavaScript object. JSHandles can be created with the [`method: Page.evaluateHandle`]()
+method.
```js
const windowHandle = await page.evaluateHandle(() => window);
// ...
```
-JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with
-[jsHandle.dispose()](). JSHandles are auto-disposed when their origin frame gets navigated or the parent context gets
+JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with [`method:
+JSHandle.dispose`](). JSHandles are auto-disposed when their origin frame gets navigated or the parent context gets
destroyed.
-JSHandle instances can be used as an argument in [page.$eval()](), [page.evaluate()]() and [page.evaluateHandle()]()
-methods.
+JSHandle instances can be used as an argument in [`method: Page.$eval`](), [`method: Page.evaluate`]() and [`method:
+Page.evaluateHandle`]() methods.
<!-- GEN:toc -->
<!-- GEN:stop -->
@@ -3840,12 +3864,12 @@ The `jsHandle.dispose` method stops referencing the element handle.
## async method: JSHandle.evaluate
- returns: <[Serializable]>
-Returns the return value of `pageFunction`
+Returns the return value of [`param: pageFunction`]()
-This method passes this handle as the first argument to `pageFunction`.
+This method passes this handle as the first argument to [`param: pageFunction`]().
-If `pageFunction` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its
-value.
+If [`param: pageFunction`]() returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and
+return its value.
Examples:
@@ -3862,14 +3886,14 @@ Function to be evaluated in browser context
### param: JSHandle.evaluate.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: JSHandle.evaluateHandle
- returns: <[JSHandle]>
-Returns the return value of `pageFunction` as in-page object (JSHandle).
+Returns the return value of [`param: pageFunction`]() as in-page object (JSHandle).
-This method passes this handle as the first argument to `pageFunction`.
+This method passes this handle as the first argument to [`param: pageFunction`]().
The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns
in-page object (JSHandle).
@@ -3877,7 +3901,7 @@ in-page object (JSHandle).
If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait
for the promise to resolve and return its value.
-See [page.evaluateHandle()]() for more details.
+See [`method: Page.evaluateHandle`]() for more details.
### param: JSHandle.evaluateHandle.pageFunction
- `pageFunction` <[function]|[string]>
@@ -3887,7 +3911,7 @@ Function to be evaluated
### param: JSHandle.evaluateHandle.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: JSHandle.getProperties
- returns: <[Map]<[string], [JSHandle]>>
@@ -3924,7 +3948,7 @@ error if the object has circular references.
# class: ConsoleMessage
-[ConsoleMessage] objects are dispatched by page via the [page.on('console')]() event.
+[ConsoleMessage] objects are dispatched by page via the [`event: Page.console`]() event.
<!-- GEN:toc -->
<!-- GEN:stop -->
@@ -3950,7 +3974,7 @@ One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'
# class: Dialog
-[Dialog] objects are dispatched by page via the [page.on('dialog')]() event.
+[Dialog] objects are dispatched by page via the [`event: Page.dialog`]() event.
An example of using `Dialog` class:
@@ -4002,7 +4026,7 @@ Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prom
# class: Download
-[Download] objects are dispatched by page via the [page.on('download')]() event.
+[Download] objects are dispatched by page via the [`event: Page.download`]() event.
All the downloaded files belonging to the browser context are deleted when the browser context is closed. All downloaded
files are deleted when the browser closes.
@@ -4086,7 +4110,7 @@ upon closing the browser context.
# class: FileChooser
-[FileChooser] objects are dispatched by the page in the [page.on('filechooser')]() event.
+[FileChooser] objects are dispatched by the page in the [`event: Page.filechooser`]() event.
```js
page.on('filechooser', async (fileChooser) => {
@@ -4115,8 +4139,7 @@ Returns page this file chooser belongs to.
## async method: FileChooser.setFiles
Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then
-they are resolved relative to the the current working directory.
-For empty array, clears the selected files.
+they are resolved relative to the the current working directory. For empty array, clears the selected files.
### param: FileChooser.setFiles.files = %%-input-files-%%
@@ -4126,11 +4149,11 @@ For empty array, clears the selected files.
# class: Keyboard
-Keyboard provides an api for managing a virtual keyboard. The high level api is [keyboard.type()](), which takes raw
-characters and generates proper keydown, keypress/input, and keyup events on your page.
+Keyboard provides an api for managing a virtual keyboard. The high level api is [`method: Keyboard.type`](), which takes
+raw characters and generates proper keydown, keypress/input, and keyup events on your page.
-For finer control, you can use [keyboard.down()](), [keyboard.up()](), and [keyboard.insertText()]() to manually fire
-events as if they were generated from a real keyboard.
+For finer control, you can use [`method: Keyboard.down`](), [`method: Keyboard.up`](), and [`method:
+Keyboard.insertText`]() to manually fire events as if they were generated from a real keyboard.
An example of holding down `Shift` in order to select and delete some text:
@@ -4171,8 +4194,9 @@ await page.keyboard.press('Meta+A');
Dispatches a `keydown` event.
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
+[`param: key`]() can specify the intended
+[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
+generate the text for. A superset of the [`param: key`]() values can be found
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
@@ -4180,17 +4204,17 @@ value or a single character to generate the text for. A superset of the `key` va
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
-Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
+Holding down `Shift` will type the text that corresponds to the [`param: key`]() in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If [`param: key`]() is a single character, it is case-sensitive, so the values `a` and `A` will generate different
+respective texts.
-If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier
-active. To release the modifier key, use [keyboard.up()]().
+If [`param: key`]() is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with
+that modifier active. To release the modifier key, use [`method: Keyboard.up`]().
-After the key is pressed once, subsequent calls to [keyboard.down()]() will have
+After the key is pressed once, subsequent calls to [`method: Keyboard.down`]() will have
[repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
-[keyboard.up()]().
+[`method: Keyboard.up`]().
> **NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
@@ -4216,8 +4240,9 @@ Sets input to the specified text value.
## async method: Keyboard.press
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
+[`param: key`]() can specify the intended
+[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
+generate the text for. A superset of the [`param: key`]() values can be found
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
@@ -4225,10 +4250,10 @@ value or a single character to generate the text for. A superset of the `key` va
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
-Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
+Holding down `Shift` will type the text that corresponds to the [`param: key`]() in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If [`param: key`]() is a single character, it is case-sensitive, so the values `a` and `A` will generate different
+respective texts.
Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
modifier, modifier is pressed and being held while the subsequent key is being pressed.
@@ -4245,7 +4270,7 @@ await page.screenshot({ path: 'O.png' });
await browser.close();
```
-Shortcut for [keyboard.down()]() and [keyboard.up()]().
+Shortcut for [`method: Keyboard.down`]() and [`method: Keyboard.up`]().
### param: Keyboard.press.key
- `key` <[string]>
@@ -4261,7 +4286,7 @@ Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
-To press a special key, like `Control` or `ArrowDown`, use [keyboard.press()]().
+To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`]().
```js
await page.keyboard.type('Hello'); // Types instantly
@@ -4311,7 +4336,7 @@ await page.mouse.up();
## async method: Mouse.click
-Shortcut for [mouse.move()](), [mouse.down()](), [mouse.up()]().
+Shortcut for [`method: Mouse.move`](), [`method: Mouse.down`](), [`method: Mouse.up`]().
### param: Mouse.click.x
- `x` <[number]>
@@ -4327,7 +4352,8 @@ Shortcut for [mouse.move()](), [mouse.down()](), [mouse.up()]().
## async method: Mouse.dblclick
-Shortcut for [mouse.move()](), [mouse.down()](), [mouse.up()](), [mouse.down()]() and [mouse.up()]().
+Shortcut for [`method: Mouse.move`](), [`method: Mouse.down`](), [`method: Mouse.up`](), [`method: Mouse.down`]() and
+[`method: Mouse.up`]().
### param: Mouse.dblclick.x
- `x` <[number]>
@@ -4377,7 +4403,7 @@ touchscreen can only be used in browser contexts that have been intialized with
## async method: Touchscreen.tap
-Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
+Dispatches a `touchstart` and `touchend` event with a single touch at the position ([`param: x`](),[`param: y`]()).
### param: Touchscreen.tap.x
- `x` <[number]>
@@ -4388,12 +4414,12 @@ Dispatches a `touchstart` and `touchend` event with a single touch at the positi
# class: Request
Whenever the page sends a request for a network resource the following sequence of events are emitted by [Page]:
-- [page.on('request')]() emitted when the request is issued by the page.
-- [page.on('response')]() emitted when/if the response status and headers are received for the request.
-- [page.on('requestfinished')]() emitted when the response body is downloaded and the request is complete.
+- [`event: Page.request`]() emitted when the request is issued by the page.
+- [`event: Page.response`]() emitted when/if the response status and headers are received for the request.
+- [`event: Page.requestfinished`]() emitted when the response body is downloaded and the request is complete.
If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event),
-the [page.on('requestfailed')]() event is emitted.
+the [`event: Page.requestfailed`]() event is emitted.
> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
will complete with `'requestfinished'` event.
@@ -4484,7 +4510,7 @@ console.log(response.request().redirectedFrom()); // null
New request issued by the browser if the server responded with redirect.
-This method is the opposite of [request.redirectedFrom()]():
+This method is the opposite of [`method: Request.redirectedFrom`]():
```js
console.log(request.redirectedFrom().redirectedTo() === request); // true
@@ -4670,8 +4696,8 @@ guaranteed when this engine is used together with other registered engines.
# class: Route
-Whenever a network route is set up with [page.route()]() or [browserContext.route()](), the `Route` object allows to
-handle the route.
+Whenever a network route is set up with [`method: Page.route`]() or [`method: BrowserContext.route`](), the `Route`
+object allows to handle the route.
<!-- GEN:toc -->
<!-- GEN:stop -->
@@ -4822,8 +4848,8 @@ Either a predicate that receives an event or an options object. Optional.
# class: TimeoutError
* extends: [Error]
-TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. [page.waitForSelector()]() or
-[browserType.launch()]().
+TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. [`method:
+Page.waitForSelector`]() or [`method: BrowserType.launch`]().
# class: Accessibility
@@ -4877,7 +4903,8 @@ Captures the current state of the accessibility tree. The returned object repres
page.
> **NOTE** The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
-Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
+Playwright will discard them as well for an easier to process tree, unless [`option: interestingOnly`]() is set to
+`false`.
An example of dumping the entire accessibility tree:
@@ -4942,7 +4969,7 @@ Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs
## async method: Worker.evaluate
- returns: <[Serializable]>
-Returns the return value of `pageFunction`
+Returns the return value of [`param: pageFunction`]()
If the function passed to the `worker.evaluate` returns a [Promise], then `worker.evaluate` would wait for the promise
to resolve and return its value.
@@ -4959,12 +4986,12 @@ Function to be evaluated in the worker context
### param: Worker.evaluate.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## async method: Worker.evaluateHandle
- returns: <[JSHandle]>
-Returns the return value of `pageFunction` as in-page object (JSHandle).
+Returns the return value of [`param: pageFunction`]() as in-page object (JSHandle).
The only difference between `worker.evaluate` and `worker.evaluateHandle` is that `worker.evaluateHandle` returns
in-page object (JSHandle).
@@ -4980,7 +5007,7 @@ Function to be evaluated in the page context
### param: Worker.evaluateHandle.arg
- `arg` <[EvaluationArgument]>
-Optional argument to pass to `pageFunction`
+Optional argument to pass to [`param: pageFunction`]()
## method: Worker.url
- returns: <[string]>
@@ -5012,8 +5039,8 @@ Spawned browser application process.
Browser websocket url.
-Browser websocket endpoint which can be used as an argument to [browserType.connect()]() to establish connection to the
-browser.
+Browser websocket endpoint which can be used as an argument to [`method: BrowserType.connect`]() to establish connection
+to the browser.
# class: BrowserType
@@ -5057,7 +5084,7 @@ A path where Playwright expects to find a bundled browser executable.
Returns the browser instance.
-You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
+You can use [`option: ignoreDefaultArgs`]() to filter out `--mute-audio` from default arguments:
```js
const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
@@ -5066,14 +5093,14 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
```
> **Chromium-only** Playwright can also be used to control the Chrome browser, but it works best with the version of
-Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath` option with
-extreme caution.
+Chromium it is bundled with. There is no guarantee it will work with any other version. Use [`option: executablePath`]()
+option with extreme caution.
>
> If Google Chrome (rather than Chromium) is preferred, a [Chrome
Canary](https://www.google.com/chrome/browser/canary.html) or [Dev
Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested.
>
-> In [browserType.launch()]() above, any mention of Chromium also applies to Chrome.
+> In [`method: BrowserType.launch`]() above, any mention of Chromium also applies to Chrome.
>
> See [`this article`](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for
a description of the differences between Chromium and Chrome. [`This
@@ -5086,14 +5113,14 @@ some differences for Linux users.
Whether to run browser in headless mode. More details for
[Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode). Defaults to `true` unless the
-`devtools` option is `true`.
+[`option: devtools`]() option is `true`.
### option: BrowserType.launch.executablePath
- `executablePath` <[string]>
-Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
-resolved relative to the current working directory. Note that
-Playwright only works with the bundled Chromium, Firefox or WebKit, use at your own risk.
+Path to a browser executable to run instead of the bundled one. If [`option: executablePath`]() is a relative path, then
+it is resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium,
+Firefox or WebKit, use at your own risk.
### option: BrowserType.launch.args
- `args` <[Array]<[string]>>
@@ -5104,8 +5131,8 @@ Additional arguments to pass to the browser instance. The list of Chromium flags
### option: BrowserType.launch.ignoreDefaultArgs
- `ignoreDefaultArgs` <[boolean]|[Array]<[string]>>
-If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is
-given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`.
+If `true`, Playwright does not pass its own configurations args and only uses the ones from [`option: args`](). If an
+array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`.
### option: BrowserType.launch.proxy
- `proxy` <[Object]>
@@ -5167,8 +5194,8 @@ Specify environment variables that will be visible to the browser. Defaults to `
### option: BrowserType.launch.devtools
- `devtools` <[boolean]>
-**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the `headless`
-option will be set `false`.
+**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [`option:
+headless`]() option will be set `false`.
### option: BrowserType.launch.slowMo
- `slowMo` <[number]>
@@ -5180,8 +5207,8 @@ Slows down Playwright operations by the specified amount of milliseconds. Useful
Returns the persistent browser context instance.
-Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this
-context will automatically close the browser.
+Launches browser that uses persistent storage located at [`param: userDataDir`]() and returns the only context. Closing
+this context will automatically close the browser.
### param: BrowserType.launchPersistentContext.userDataDir
- `userDataDir` <[string]>
@@ -5196,14 +5223,14 @@ Path to a User Data Directory, which stores browser session data like cookies an
Whether to run browser in headless mode. More details for
[Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode). Defaults to `true` unless the
-`devtools` option is `true`.
+[`option: devtools`]() option is `true`.
### option: BrowserType.launchPersistentContext.executablePath
- `executablePath` <[string]>
-Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
-resolved relative to the current working directory. **BEWARE**:
-Playwright is only guaranteed to work with the bundled Chromium, Firefox or WebKit, use at your own risk.
+Path to a browser executable to run instead of the bundled one. If [`option: executablePath`]() is a relative path, then
+it is resolved relative to the current working directory. **BEWARE**: Playwright is only guaranteed to work with the
+bundled Chromium, Firefox or WebKit, use at your own risk.
### option: BrowserType.launchPersistentContext.args
- `args` <[Array]<[string]>>
@@ -5266,8 +5293,8 @@ Specify environment variables that will be visible to the browser. Defaults to `
### option: BrowserType.launchPersistentContext.devtools
- `devtools` <[boolean]>
-**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the `headless`
-option will be set `false`.
+**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [`option:
+headless`]() option will be set `false`.
### option: BrowserType.launchPersistentContext.slowMo
- `slowMo` <[number]>
@@ -5304,7 +5331,7 @@ const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'.
Whether to run browser in headless mode. More details for
[Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode). Defaults to `true` unless the
-`devtools` option is `true`.
+[`option: devtools`]() option is `true`.
### option: BrowserType.launchServer.port
- `port` <[number]>
@@ -5314,9 +5341,9 @@ Port to use for the web socket. Defaults to 0 that picks any available port.
### option: BrowserType.launchServer.executablePath
- `executablePath` <[string]>
-Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
-resolved relative to the current working directory. **BEWARE**:
-Playwright is only guaranteed to work with the bundled Chromium, Firefox or WebKit, use at your own risk.
+Path to a browser executable to run instead of the bundled one. If [`option: executablePath`]() is a relative path, then
+it is resolved relative to the current working directory. **BEWARE**: Playwright is only guaranteed to work with the
+bundled Chromium, Firefox or WebKit, use at your own risk.
### option: BrowserType.launchServer.args
- `args` <[Array]<[string]>>
@@ -5390,8 +5417,8 @@ Specify environment variables that will be visible to the browser. Defaults to `
### option: BrowserType.launchServer.devtools
- `devtools` <[boolean]>
-**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the `headless`
-option will be set `false`.
+**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [`option:
+headless`]() option will be set `false`.
## method: BrowserType.name
- returns: <[string]>
@@ -5461,9 +5488,9 @@ optional formatting hints
# class: ChromiumBrowser
* extends: [Browser]
-Chromium-specific features including Tracing, service worker support, etc. You can use
-[chromiumBrowser.startTracing()]() and [chromiumBrowser.stopTracing()]() to create a trace file which can be opened in
-Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/).
+Chromium-specific features including Tracing, service worker support, etc. You can use [`method:
+ChromiumBrowser.startTracing`]() and [`method: ChromiumBrowser.stopTracing`]() to create a trace file which can be
+opened in Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/).
```js
await browser.startTracing(page, {path: 'trace.json'});
@@ -5601,8 +5628,8 @@ Whether to reset coverage on every navigation. Defaults to `true`.
Returns coverage is started
> **NOTE** Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created
-on the page using `eval` or `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous scripts will have
-`__playwright_evaluation_script__` as their URL.
+on the page using `eval` or `new Function`. If [`option: reportAnonymousScripts`]() is set to `true`, anonymous scripts
+will have `__playwright_evaluation_script__` as their URL.
### option: ChromiumCoverage.startJSCoverage.resetOnNavigation
- `resetOnNavigation` <[boolean]>
@@ -5622,7 +5649,6 @@ Whether anonymous scripts generated by the page should be reported. Defaults to
- `start` <[number]> A start offset in text, inclusive
- `end` <[number]> An end offset in text, exclusive
-
Returns the array of coverage reports for all stylesheets
> **NOTE** CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
diff --git a/docs-src/api-header.md b/docs-src/api-header.md
index 1814d6e1a7..e4913635d1 100644
--- a/docs-src/api-header.md
+++ b/docs-src/api-header.md
@@ -77,7 +77,7 @@ This object can be used to launch or connect to Chromium, returning instances of
#### playwright.devices
- returns: <[Object]>
-Returns a list of devices to be used with [`browser.newContext([options])`](#browsernewcontextoptions) or [`browser.newPage([options])`](#browsernewpageoptions). Actual list of devices can be found in [src/server/deviceDescriptors.ts](https://github.com/Microsoft/playwright/blob/master/src/server/deviceDescriptors.ts).
+Returns a list of devices to be used with [`method: Browser.newContext`]() or [`method: Browser.newPage`](). Actual list of devices can be found in [src/server/deviceDescriptors.ts](https://github.com/Microsoft/playwright/blob/master/src/server/deviceDescriptors.ts).
```js
const { webkit, devices } = require('playwright');
@@ -99,7 +99,7 @@ const iPhone = devices['iPhone 6'];
- returns: <[Object]>
- `TimeoutError` <[function]> A class of [TimeoutError].
-Playwright methods might throw errors if they are unable to fulfill a request. For example, [page.waitForSelector(selector[, options])](#pagewaitforselectorselector-options)
+Playwright methods might throw errors if they are unable to fulfill a request. For example, [`method: Page.waitForSelector`]()
might fail if the selector doesn't match any nodes during the given timeframe.
For certain types of errors Playwright uses specific error classes.
diff --git a/docs-src/api-params.md b/docs-src/api-params.md
index 4136f05248..918c439efe 100644
--- a/docs-src/api-params.md
+++ b/docs-src/api-params.md
@@ -13,25 +13,25 @@ When to consider operation succeeded, defaults to `load`. Events can be either:
Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
The default value can be changed by using the
-[browserContext.setDefaultNavigationTimeout()](),
-[browserContext.setDefaultTimeout()](),
-[page.setDefaultNavigationTimeout()]() or
-[page.setDefaultTimeout()]() methods.
+[`method: BrowserContext.setDefaultNavigationTimeout`](),
+[`method: BrowserContext.setDefaultTimeout`](),
+[`method: Page.setDefaultNavigationTimeout`]() or
+[`method: Page.setDefaultTimeout`]() methods.
## wait-for-timeout
- `timeout` <[number]>
maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
-value can be changed by using the [browserContext.setDefaultTimeout()]().
+value can be changed by using the [`method: BrowserContext.setDefaultTimeout`]().
## input-timeout
- `timeout` <[number]>
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
-using the [browserContext.setDefaultTimeout()]() or
-[page.setDefaultTimeout()]() methods.
+using the [`method: BrowserContext.setDefaultTimeout`]() or
+[`method: Page.setDefaultTimeout`]() methods.
## input-no-wait-after
@@ -133,7 +133,7 @@ Defaults to `'visible'`. Can be either:
- `value` <[string]>
Populates context with given storage state. This method can be used to initialize context with logged-in information
-obtained via [browserContext.storageState()](). Either a path to the file with saved storage, or an object with the following fields:
+obtained via [`method: BrowserContext.storageState`](). Either a path to the file with saved storage, or an object with the following fields:
## context-option-acceptdownloads
@@ -218,7 +218,7 @@ request header value as well as number and date formatting rules.
- `permissions` <[Array]<[string]>>
A list of permissions to grant to all pages in this context. See
-[browserContext.grantPermissions()]() for more details.
+[`method: BrowserContext.grantPermissions`]() for more details.
## context-option-extrahttpheaders
@@ -245,7 +245,7 @@ Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/W
- `colorScheme` <"light"|"dark"|"no-preference">
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
-[page.emulateMedia()]() for more details. Defaults to '`light`'.
+[`method: Page.emulateMedia`]() for more details. Defaults to '`light`'.
## context-option-logger
@@ -257,9 +257,9 @@ Logger sink for Playwright logging.
- `videosPath` <[string]>
-**NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to
+**NOTE** Use [`param: recordVideo`]() instead, it takes precedence over `videosPath`. Enables video recording for all pages to
`videosPath` directory. If not specified, videos are not recorded. Make sure to await
-[browserContext.close()]() for videos to be saved.
+[`method: BrowserContext.close`]() for videos to be saved.
## context-option-videosize
@@ -267,7 +267,7 @@ Logger sink for Playwright logging.
- `width` <[number]> Video frame width.
- `height` <[number]> Video frame height.
-**NOTE** Use `recordVideo` instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically
+**NOTE** Use [`param: recordVideo`]() instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically
recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If
`viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled
down if necessary to fit specified size.
@@ -280,7 +280,7 @@ down if necessary to fit specified size.
- `path` <[string]> Path on the filesystem to write the HAR file to.
Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not
-specified, the HAR is not recorded. Make sure to await [browserContext.close()]() for the HAR to be
+specified, the HAR is not recorded. Make sure to await [`method: BrowserContext.close`]() for the HAR to be
saved.
## context-option-recordvideo
@@ -294,7 +294,7 @@ saved.
- `height` <[number]> Video frame height.
Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make
-sure to await [browserContext.close()]() for videos to be saved.
+sure to await [`method: BrowserContext.close`]() for videos to be saved.
## context-option-proxy
diff --git a/docs/api.md b/docs/api.md
index 5714367ffc..776a29bebc 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -100,7 +100,7 @@ const iPhone = devices['iPhone 6'];
- returns: <[Object]>
- `TimeoutError` <[function]> A class of [TimeoutError].
-Playwright methods might throw errors if they are unable to fulfill a request. For example, [page.waitForSelector(selector[, options])](#pagewaitforselectorselector-options)
+Playwright methods might throw errors if they are unable to fulfill a request. For example, [`page.waitForSelector(selector[, options])`](#pagewaitforselectorselector-options)
might fail if the selector doesn't match any nodes during the given timeframe.
For certain types of errors Playwright uses specific error classes.
@@ -137,8 +137,7 @@ This object can be used to launch or connect to WebKit, returning instances of [
### class: Browser
* extends: [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
-A Browser is created when Playwright connects to a browser instance, either through [browserType.launch([options])](#browsertypelaunchoptions) or
-[browserType.connect(params)](#browsertypeconnectparams).
+A Browser is created when Playwright connects to a browser instance, either through [`browserType.launch([options])`](#browsertypelaunchoptions) or [`browserType.connect(params)`](#browsertypeconnectparams).
An example of using a [Browser] to create a [Page]:
@@ -153,9 +152,7 @@ const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
})();
```
-See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific features. Note that
-[browserType.connect(params)](#browsertypeconnectparams) and [browserType.launch([options])](#browsertypelaunchoptions) always return a specific browser instance, based on the browser
-being connected to or launched.
+See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific features. Note that [`browserType.connect(params)`](#browsertypeconnectparams) and [`browserType.launch([options])`](#browsertypelaunchoptions) always return a specific browser instance, based on the browser being connected to or launched.
<!-- GEN:toc -->
- [browser.on('disconnected')](#browserondisconnected)
@@ -171,16 +168,14 @@ being connected to or launched.
Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
* Browser application is closed or crashed.
-* The [browser.close()](#browserclose) method was called.
+* The [`browser.close()`](#browserclose) method was called.
#### browser.close()
- returns: <[Promise]>
-In case this browser is obtained using [browserType.launch([options])](#browsertypelaunchoptions), closes the browser and all of its pages (if any were
-opened).
+In case this browser is obtained using [`browserType.launch([options])`](#browsertypelaunchoptions), closes the browser and all of its pages (if any were opened).
-In case this browser is obtained using [browserType.connect(params)](#browsertypeconnectparams), clears all created contexts belonging to this browser
-and disconnects from the browser server.
+In case this browser is obtained using [`browserType.connect(params)`](#browsertypeconnectparams), clears all created contexts belonging to this browser and disconnects from the browser server.
The [Browser] object itself is considered to be disposed and cannot be used anymore.
@@ -221,22 +216,22 @@ Indicates that the browser is connected.
- `longitude` <[number]> Longitude between -180 and 180.
- `accuracy` <[number]> Non-negative accuracy value. Defaults to `0`.
- `locale` <[string]> Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules.
- - `permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [browserContext.grantPermissions(permissions[, options])](#browsercontextgrantpermissionspermissions-options) for more details.
+ - `permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [`browserContext.grantPermissions(permissions[, options])`](#browsercontextgrantpermissionspermissions-options) for more details.
- `extraHTTPHeaders` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
- `offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
- `httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
- `username` <[string]>
- `password` <[string]>
- - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(params)](#pageemulatemediaparams) for more details. Defaults to '`light`'.
+ - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [`page.emulateMedia(params)`](#pageemulatemediaparams) for more details. Defaults to '`light`'.
- `logger` <[Logger]> Logger sink for Playwright logging.
- - `videosPath` <[string]> **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to `videosPath` directory. If not specified, videos are not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for videos to be saved.
+ - `videosPath` <[string]> **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to `videosPath` directory. If not specified, videos are not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for videos to be saved.
- `videoSize` <[Object]> **NOTE** Use `recordVideo` instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.
- `width` <[number]> Video frame width.
- `height` <[number]> Video frame height.
- - `recordHar` <[Object]> Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for the HAR to be saved.
+ - `recordHar` <[Object]> Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for the HAR to be saved.
- `omitContent` <[boolean]> Optional setting to control whether to omit request content from the HAR. Defaults to `false`.
- `path` <[string]> Path on the filesystem to write the HAR file to.
- - `recordVideo` <[Object]> Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for videos to be saved.
+ - `recordVideo` <[Object]> Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for videos to be saved.
- `dir` <[string]> Path to the directory to put videos into.
- `size` <[Object]> Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of each page will be scaled down if necessary to fit the specified size.
- `width` <[number]> Video frame width.
@@ -246,7 +241,7 @@ Indicates that the browser is connected.
- `bypass` <[string]> Optional coma-separated domains to bypass proxy, for example `".com, chromium.org, .domain.com"`.
- `username` <[string]> Optional username to use if HTTP proxy requires authentication.
- `password` <[string]> Optional password to use if HTTP proxy requires authentication.
- - `storageState` <[string]|[Object]> Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via [browserContext.storageState([options])](#browsercontextstoragestateoptions). Either a path to the file with saved storage, or an object with the following fields:
+ - `storageState` <[string]|[Object]> Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via [`browserContext.storageState([options])`](#browsercontextstoragestateoptions). Either a path to the file with saved storage, or an object with the following fields:
- `cookies` <[Array]<[Object]>> Optional cookies to set for context
- `name` <[string]> **required**
- `value` <[string]> **required**
@@ -296,22 +291,22 @@ Creates a new browser context. It won't share cookies/cache with other browser c
- `longitude` <[number]> Longitude between -180 and 180.
- `accuracy` <[number]> Non-negative accuracy value. Defaults to `0`.
- `locale` <[string]> Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules.
- - `permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [browserContext.grantPermissions(permissions[, options])](#browsercontextgrantpermissionspermissions-options) for more details.
+ - `permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [`browserContext.grantPermissions(permissions[, options])`](#browsercontextgrantpermissionspermissions-options) for more details.
- `extraHTTPHeaders` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
- `offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
- `httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
- `username` <[string]>
- `password` <[string]>
- - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(params)](#pageemulatemediaparams) for more details. Defaults to '`light`'.
+ - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [`page.emulateMedia(params)`](#pageemulatemediaparams) for more details. Defaults to '`light`'.
- `logger` <[Logger]> Logger sink for Playwright logging.
- - `videosPath` <[string]> **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to `videosPath` directory. If not specified, videos are not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for videos to be saved.
+ - `videosPath` <[string]> **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to `videosPath` directory. If not specified, videos are not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for videos to be saved.
- `videoSize` <[Object]> **NOTE** Use `recordVideo` instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.
- `width` <[number]> Video frame width.
- `height` <[number]> Video frame height.
- - `recordHar` <[Object]> Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for the HAR to be saved.
+ - `recordHar` <[Object]> Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for the HAR to be saved.
- `omitContent` <[boolean]> Optional setting to control whether to omit request content from the HAR. Defaults to `false`.
- `path` <[string]> Path on the filesystem to write the HAR file to.
- - `recordVideo` <[Object]> Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for videos to be saved.
+ - `recordVideo` <[Object]> Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for videos to be saved.
- `dir` <[string]> Path to the directory to put videos into.
- `size` <[Object]> Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of each page will be scaled down if necessary to fit the specified size.
- `width` <[number]> Video frame width.
@@ -321,7 +316,7 @@ Creates a new browser context. It won't share cookies/cache with other browser c
- `bypass` <[string]> Optional coma-separated domains to bypass proxy, for example `".com, chromium.org, .domain.com"`.
- `username` <[string]> Optional username to use if HTTP proxy requires authentication.
- `password` <[string]> Optional password to use if HTTP proxy requires authentication.
- - `storageState` <[string]|[Object]> Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via [browserContext.storageState([options])](#browsercontextstoragestateoptions). Either a path to the file with saved storage, or an object with the following fields:
+ - `storageState` <[string]|[Object]> Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via [`browserContext.storageState([options])`](#browsercontextstoragestateoptions). Either a path to the file with saved storage, or an object with the following fields:
- `cookies` <[Array]<[Object]>> Optional cookies to set for context
- `name` <[string]> **required**
- `value` <[string]> **required**
@@ -341,9 +336,7 @@ Creates a new browser context. It won't share cookies/cache with other browser c
Creates a new page in a new browser context. Closing this page will close the context as well.
-This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
-testing frameworks should explicitly create [browser.newContext([options])](#browsernewcontextoptions) followed by the [browserContext.newPage()](#browsercontextnewpage) to
-control their exact life times.
+This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and testing frameworks should explicitly create [`browser.newContext([options])`](#browsernewcontextoptions) followed by the [`browserContext.newPage()`](#browsercontextnewpage) to control their exact life times.
#### browser.version()
- returns: <[string]>
@@ -355,11 +348,9 @@ Returns the browser version.
BrowserContexts provide a way to operate multiple independent browser sessions.
-If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser
-context.
+If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser context.
-Playwright allows creation of "incognito" browser contexts with `browser.newContext()` method. "Incognito" browser
-contexts don't write any browsing data to disk.
+Playwright allows creation of "incognito" browser contexts with `browser.newContext()` method. "Incognito" browser contexts don't write any browsing data to disk.
```js
// Create a new incognito browser context
@@ -403,17 +394,14 @@ await context.close();
Emitted when Browser context gets closed. This might happen because of one of the following:
* Browser context is closed.
* Browser application is closed or crashed.
-* The [browser.close()](#browserclose) method was called.
+* The [`browser.close()`](#browserclose) method was called.
#### browserContext.on('page')
- <[Page]>
-The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
-also fire for popup pages. See also [page.on('popup')](#pageonpopup) to receive events about popups relevant to a specific page.
+The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will also fire for popup pages. See also [page.on('popup')](#pageonpopup) to receive events about popups relevant to a specific page.
-The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
-popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
-done and its response has started loading in the popup.
+The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is done and its response has started loading in the popup.
```js
const [page] = await Promise.all([
@@ -423,8 +411,7 @@ const [page] = await Promise.all([
console.log(await page.evaluate('location.href'));
```
-> **NOTE** Use [page.waitForLoadState([state, options])](#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in
-most cases).
+> **NOTE** Use [`page.waitForLoadState([state, options])`](#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in most cases).
#### browserContext.addCookies(cookies)
- `cookies` <[Array]<[Object]>>
@@ -439,8 +426,7 @@ most cases).
- `sameSite` <"Strict"|"Lax"|"None">
- returns: <[Promise]>
-Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
-obtained via [browserContext.cookies([urls])](#browsercontextcookiesurls).
+Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be obtained via [`browserContext.cookies([urls])`](#browsercontextcookiesurls).
```js
await browserContext.addCookies([cookieObject1, cookieObject2]);
@@ -457,8 +443,7 @@ Adds a script which would be evaluated in one of the following scenarios:
* Whenever a page is created in the browser context or is navigated.
* Whenever a child frame is attached or navigated in any page in the browser context. In this case, the script is evaluated in the context of the newly attached frame.
-The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
-the JavaScript environment, e.g. to seed `Math.random`.
+The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed `Math.random`.
An example of overriding `Math.random` before the page loads:
@@ -474,8 +459,7 @@ await browserContext.addInitScript({
});
```
-> **NOTE** The order of evaluation of multiple scripts installed via [browserContext.addInitScript(script[, arg])](#browsercontextaddinitscriptscript-arg) and
-[page.addInitScript(script[, arg])](#pageaddinitscriptscript-arg) is not defined.
+> **NOTE** The order of evaluation of multiple scripts installed via [`browserContext.addInitScript(script[, arg])`](#browsercontextaddinitscriptscript-arg) and [`page.addInitScript(script[, arg])`](#pageaddinitscriptscript-arg) is not defined.
#### browserContext.browser()
- returns: <[null]|[Browser]>
@@ -518,8 +502,7 @@ Closes the browser context. All the pages that belong to the browser context wil
- `secure` <[boolean]>
- `sameSite` <"Strict"|"Lax"|"None">
-If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs
-are returned.
+If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs are returned.
#### browserContext.exposeBinding(name, playwrightBinding[, options])
- `name` <[string]> Name of the function on the window object.
@@ -528,14 +511,11 @@ are returned.
- `handle` <[boolean]> Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is supported. When passing by value, multiple arguments are supported.
- returns: <[Promise]>
-The method adds a function called `name` on the `window` object of every frame in every page in the context. When
-called, the function executes `playwrightBinding` and returns a [Promise] which resolves to the return value of
-`playwrightBinding`. If the `playwrightBinding` returns a [Promise], it will be awaited.
+The method adds a function called `name` on the `window` object of every frame in every page in the context. When called, the function executes `playwrightBinding` and returns a [Promise] which resolves to the return value of `playwrightBinding`. If the `playwrightBinding` returns a [Promise], it will be awaited.
-The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext:
-BrowserContext, page: Page, frame: Frame }`.
+The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext: BrowserContext, page: Page, frame: Frame }`.
-See [page.exposeBinding(name, playwrightBinding[, options])](#pageexposebindingname-playwrightbinding-options) for page-only version.
+See [`page.exposeBinding(name, playwrightBinding[, options])`](#pageexposebindingname-playwrightbinding-options) for page-only version.
An example of exposing page URL to all frames in all pages in the context:
@@ -580,13 +560,11 @@ await page.setContent(`
- `playwrightFunction` <[function]> Callback function that will be called in the Playwright's context.
- returns: <[Promise]>
-The method adds a function called `name` on the `window` object of every frame in every page in the context. When
-called, the function executes `playwrightFunction` and returns a [Promise] which resolves to the return value of
-`playwrightFunction`.
+The method adds a function called `name` on the `window` object of every frame in every page in the context. When called, the function executes `playwrightFunction` and returns a [Promise] which resolves to the return value of `playwrightFunction`.
If the `playwrightFunction` returns a [Promise], it will be awaited.
-See [page.exposeFunction(name, playwrightFunction)](#pageexposefunctionname-playwrightfunction) for page-only version.
+See [`page.exposeFunction(name, playwrightFunction)`](#pageexposefunctionname-playwrightfunction) for page-only version.
An example of adding an `md5` function to all pages in the context:
@@ -634,8 +612,7 @@ const crypto = require('crypto');
- `origin` <[string]> The [origin] to grant permissions to, e.g. "https://example.com".
- returns: <[Promise]>
-Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
-specified.
+Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if specified.
#### browserContext.newPage()
- returns: <[Promise]<[Page]>>
@@ -645,16 +622,14 @@ Creates a new page in the browser context.
#### browserContext.pages()
- returns: <[Array]<[Page]>>
-Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can
-find them using [chromiumBrowserContext.backgroundPages()](#chromiumbrowsercontextbackgroundpages).
+Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can find them using [`chromiumBrowserContext.backgroundPages()`](#chromiumbrowsercontextbackgroundpages).
#### browserContext.route(url, handler)
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
- `handler` <[function]\([Route], [Request]\)> handler function to route the request.
- returns: <[Promise]>
-Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
-is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
+Routing provides the capability to modify network requests that are made by any page in the browser context. Once route is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
An example of a naïve handler that aborts all image requests:
@@ -676,8 +651,7 @@ await page.goto('https://example.com');
await browser.close();
```
-Page routes (set up with [page.route(url, handler)](#pagerouteurl-handler)) take precedence over browser context routes when request matches both
-handlers.
+Page routes (set up with [`page.route(url, handler)`](#pagerouteurl-handler)) take precedence over browser context routes when request matches both handlers.
> **NOTE** Enabling routing disables http cache.
@@ -685,31 +659,27 @@ handlers.
- `timeout` <[number]> Maximum navigation time in milliseconds
This setting will change the default maximum navigation time for the following methods and related shortcuts:
-* [page.goBack([options])](#pagegobackoptions)
-* [page.goForward([options])](#pagegoforwardoptions)
-* [page.goto(url[, options])](#pagegotourl-options)
-* [page.reload([options])](#pagereloadoptions)
-* [page.setContent(html[, options])](#pagesetcontenthtml-options)
-* [page.waitForNavigation([options])](#pagewaitfornavigationoptions)
+* [`page.goBack([options])`](#pagegobackoptions)
+* [`page.goForward([options])`](#pagegoforwardoptions)
+* [`page.goto(url[, options])`](#pagegotourl-options)
+* [`page.reload([options])`](#pagereloadoptions)
+* [`page.setContent(html[, options])`](#pagesetcontenthtml-options)
+* [`page.waitForNavigation([options])`](#pagewaitfornavigationoptions)
-> **NOTE** [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) and [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) take priority over
-[browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout).
+> **NOTE** [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) and [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) take priority over [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout).
#### browserContext.setDefaultTimeout(timeout)
- `timeout` <[number]> Maximum time in milliseconds
This setting will change the default maximum time for all the methods accepting `timeout` option.
-> **NOTE** [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout), [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) and
-[browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout) take priority over [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout).
+> **NOTE** [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout), [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) and [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout) take priority over [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout).
#### browserContext.setExtraHTTPHeaders(headers)
- `headers` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
- returns: <[Promise]>
-The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
-with page-specific extra HTTP headers set with [page.setExtraHTTPHeaders(headers)](#pagesetextrahttpheadersheaders). If page overrides a particular header,
-page-specific header value will be used instead of the browser context header value.
+The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged with page-specific extra HTTP headers set with [`page.setExtraHTTPHeaders(headers)`](#pagesetextrahttpheadersheaders). If page overrides a particular header, page-specific header value will be used instead of the browser context header value.
> **NOTE** `browserContext.setExtraHTTPHeaders` does not guarantee the order of headers in the outgoing requests.
@@ -726,8 +696,7 @@ Sets the context's geolocation. Passing `null` or `undefined` emulates position
await browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});
```
-> **NOTE** Consider using [browserContext.grantPermissions(permissions[, options])](#browsercontextgrantpermissionspermissions-options) to grant permissions for the browser context pages to
-read its geolocation.
+> **NOTE** Consider using [`browserContext.grantPermissions(permissions[, options])`](#browsercontextgrantpermissionspermissions-options) to grant permissions for the browser context pages to read its geolocation.
#### browserContext.setHTTPCredentials(httpCredentials)
- `httpCredentials` <[null]|[Object]>
@@ -737,9 +706,7 @@ read its geolocation.
Provide credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
-> **NOTE** Browsers may cache credentials after successful authentication. Passing different credentials or passing
-`null` to disable authentication will be unreliable. To remove or replace credentials, create a new browser context
-instead.
+> **NOTE** Browsers may cache credentials after successful authentication. Passing different credentials or passing `null` to disable authentication will be unreliable. To remove or replace credentials, create a new browser context instead.
#### browserContext.setOffline(offline)
- `offline` <[boolean]> Whether to emulate network being offline for the browser context.
@@ -767,12 +734,11 @@ instead.
Returns storage state for this browser context, contains current cookies and local storage snapshot.
#### browserContext.unroute(url[, handler])
-- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with [browserContext.route(url, handler)](#browsercontextrouteurl-handler).
-- `handler` <[function]\([Route], [Request]\)> Optional handler function used to register a routing with [browserContext.route(url, handler)](#browsercontextrouteurl-handler).
+- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with [`browserContext.route(url, handler)`](#browsercontextrouteurl-handler).
+- `handler` <[function]\([Route], [Request]\)> Optional handler function used to register a routing with [`browserContext.route(url, handler)`](#browsercontextrouteurl-handler).
- returns: <[Promise]>
-Removes a route created with [browserContext.route(url, handler)](#browsercontextrouteurl-handler). When `handler` is not specified, removes all routes for the
-`url`.
+Removes a route created with [`browserContext.route(url, handler)`](#browsercontextrouteurl-handler). When `handler` is not specified, removes all routes for the `url`.
#### browserContext.waitForEvent(event[, optionsOrPredicate])
- `event` <[string]> Event name, same one would pass into `browserContext.on(event)`.
@@ -781,8 +747,7 @@ Removes a route created with [browserContext.route(url, handler)](#browsercontex
- `timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout).
- returns: <[Promise]<[Object]>>
-Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
-value. Will throw an error if the context closes before the event is fired. Returns the event data value.
+Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the context closes before the event is fired. Returns the event data value.
```js
const context = await browser.newContext();
@@ -792,9 +757,7 @@ await context.grantPermissions(['geolocation']);
### class: Page
* extends: [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
-Page provides methods to interact with a single tab in a [Browser], or an [extension background
-page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [Browser] instance might have multiple
-[Page] instances.
+Page provides methods to interact with a single tab in a [Browser], or an [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [Browser] instance might have multiple [Page] instances.
This example creates a page, navigates it to a URL, and then saves a screenshot:
@@ -811,9 +774,7 @@ const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
})();
```
-The Page class emits various events (described below) which can be handled using any of Node's native
-[`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or
-`removeListener`.
+The Page class emits various events (described below) which can be handled using any of Node's native [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or `removeListener`.
This example logs a message for a single page `load` event:
@@ -930,8 +891,7 @@ Emitted when the page closes.
#### page.on('console')
- <[ConsoleMessage]>
-Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also
-emitted if the page throws an error or a warning.
+Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also emitted if the page throws an error or a warning.
The arguments passed into `console.log` appear as arguments on the event handler.
@@ -947,8 +907,7 @@ page.evaluate(() => console.log('hello', 5, {foo: 'bar'}));
#### page.on('crash')
-Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes,
-ongoing and subsequent operations will throw.
+Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes, ongoing and subsequent operations will throw.
The most common way to deal with crashes is to catch an exception:
@@ -963,8 +922,7 @@ try {
}
```
-However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case,
-handling `crash` event helps:
+However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, handling `crash` event helps:
```js
await new Promise((resolve, reject) => {
@@ -979,29 +937,23 @@ await new Promise((resolve, reject) => {
#### page.on('dialog')
- <[Dialog]>
-Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond
-to the dialog via [dialog.accept([promptText])](#dialogacceptprompttext) or [dialog.dismiss()](#dialogdismiss) methods.
+Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via [`dialog.accept([promptText])`](#dialogacceptprompttext) or [`dialog.dismiss()`](#dialogdismiss) methods.
#### page.on('domcontentloaded')
-Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded)
-event is dispatched.
+Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.
#### page.on('download')
- <[Download]>
-Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
-[Download] instance.
+Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance.
-> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
-downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
-download is not performed and user has no access to the downloaded files.
+> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.
#### page.on('filechooser')
- <[FileChooser]>
-Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can
-respond to it via setting the input files using [fileChooser.setFiles(files[, options])](#filechoosersetfilesfiles-options) that can be uploaded after that.
+Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can respond to it via setting the input files using [`fileChooser.setFiles(files[, options])`](#filechoosersetfilesfiles-options) that can be uploaded after that.
```js
page.on('filechooser', async (fileChooser) => {
@@ -1036,12 +988,9 @@ Emitted when an uncaught exception happens within the page.
#### page.on('popup')
- <[Page]> Page corresponding to "popup" window
-Emitted when the page opens a new tab or window. This event is emitted in addition to the [browserContext.on('page')](#browsercontextonpage),
-but only for popups relevant to this page.
+Emitted when the page opens a new tab or window. This event is emitted in addition to the [browserContext.on('page')](#browsercontextonpage), but only for popups relevant to this page.
-The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
-popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
-done and its response has started loading in the popup.
+The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is done and its response has started loading in the popup.
```js
const [popup] = await Promise.all([
@@ -1051,34 +1000,29 @@ const [popup] = await Promise.all([
console.log(await popup.evaluate('location.href'));
```
-> **NOTE** Use [page.waitForLoadState([state, options])](#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in
-most cases).
+> **NOTE** Use [`page.waitForLoadState([state, options])`](#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in most cases).
#### page.on('request')
- <[Request]>
-Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see
-[page.route(url, handler)](#pagerouteurl-handler) or [browserContext.route(url, handler)](#browsercontextrouteurl-handler).
+Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see [`page.route(url, handler)`](#pagerouteurl-handler) or [`browserContext.route(url, handler)`](#browsercontextrouteurl-handler).
#### page.on('requestfailed')
- <[Request]>
Emitted when a request fails, for example by timing out.
-> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
-will complete with [page.on('requestfinished')](#pageonrequestfinished) event and not with [page.on('requestfailed')](#pageonrequestfailed).
+> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with [page.on('requestfinished')](#pageonrequestfinished) event and not with [page.on('requestfailed')](#pageonrequestfailed).
#### page.on('requestfinished')
- <[Request]>
-Emitted when a request finishes successfully after downloading the response body. For a successful response, the
-sequence of events is `request`, `response` and `requestfinished`.
+Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`.
#### page.on('response')
- <[Response]>
-Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events
-is `request`, `response` and `requestfinished`.
+Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`.
#### page.on('websocket')
- <[WebSocket]> websocket
@@ -1088,26 +1032,23 @@ Emitted when <[WebSocket]> request is sent.
#### page.on('worker')
- <[Worker]>
-Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the
-page.
+Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page.
#### page.$(selector)
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
- returns: <[Promise]<[null]|[ElementHandle]>>
-The method finds an element matching the specified selector within the page. If no elements match the selector, the
-return value resolves to `null`.
+The method finds an element matching the specified selector within the page. If no elements match the selector, the return value resolves to `null`.
-Shortcut for main frame's [frame.$(selector)](#frameselector).
+Shortcut for main frame's [`frame.$(selector)`](#frameselector).
#### page.$$(selector)
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
- returns: <[Promise]<[Array]<[ElementHandle]>>>
-The method finds all elements matching the specified selector within the page. If no elements match the selector, the
-return value resolves to `[]`.
+The method finds all elements matching the specified selector within the page. If no elements match the selector, the return value resolves to `[]`.
-Shortcut for main frame's [frame.$$(selector)](#frameselector).
+Shortcut for main frame's [`frame.$$(selector)`](#frameselector).
#### page.$eval(selector, pageFunction[, arg])
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -1115,10 +1056,9 @@ Shortcut for main frame's [frame.$$(selector)](#frameselector).
- `arg` <[EvaluationArgument]> Optional argument to pass to `pageFunction`
- returns: <[Promise]<[Serializable]>>
-The method finds an element matching the specified selector within the page and passes it as a first argument to
-`pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`.
+The method finds an element matching the specified selector within the page and passes it as a first argument to `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`.
-If `pageFunction` returns a [Promise], then `page.$eval` would wait for the promise to resolve and return its value.
+If `pageFunction` returns a [Promise], then [`page.$eval(selector, pageFunction[, arg])`](#pageevalselector-pagefunction-arg) would wait for the promise to resolve and return its value.
Examples:
@@ -1128,7 +1068,7 @@ const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
```
-Shortcut for main frame's [frame.$eval(selector, pageFunction[, arg])](#frameevalselector-pagefunction-arg).
+Shortcut for main frame's [`frame.$eval(selector, pageFunction[, arg])`](#frameevalselector-pagefunction-arg).
#### page.$$eval(selector, pageFunction[, arg])
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -1136,10 +1076,9 @@ Shortcut for main frame's [frame.$eval(selector, pageFunction[, arg])](#frameeva
- `arg` <[EvaluationArgument]> Optional argument to pass to `pageFunction`
- returns: <[Promise]<[Serializable]>>
-The method finds all elements matching the specified selector within the page and passes an array of matched elements as
-a first argument to `pageFunction`. Returns the result of `pageFunction` invocation.
+The method finds all elements matching the specified selector within the page and passes an array of matched elements as a first argument to `pageFunction`. Returns the result of `pageFunction` invocation.
-If `pageFunction` returns a [Promise], then `page.$$eval` would wait for the promise to resolve and return its value.
+If `pageFunction` returns a [Promise], then [`page.$$eval(selector, pageFunction[, arg])`](#pageevalselector-pagefunction-arg) would wait for the promise to resolve and return its value.
Examples:
@@ -1161,8 +1100,7 @@ Adds a script which would be evaluated in one of the following scenarios:
* Whenever the page is navigated.
* Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.
-The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
-the JavaScript environment, e.g. to seed `Math.random`.
+The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed `Math.random`.
An example of overriding `Math.random` before the page loads:
@@ -1175,8 +1113,7 @@ const preloadFile = fs.readFileSync('./preload.js', 'utf8');
await page.addInitScript(preloadFile);
```
-> **NOTE** The order of evaluation of multiple scripts installed via [browserContext.addInitScript(script[, arg])](#browsercontextaddinitscriptscript-arg) and
-[page.addInitScript(script[, arg])](#pageaddinitscriptscript-arg) is not defined.
+> **NOTE** The order of evaluation of multiple scripts installed via [`browserContext.addInitScript(script[, arg])`](#browsercontextaddinitscriptscript-arg) and [`page.addInitScript(script[, arg])`](#pageaddinitscriptscript-arg) is not defined.
#### page.addScriptTag(params)
- `params` <[Object]>
@@ -1186,10 +1123,9 @@ await page.addInitScript(preloadFile);
- `type` <[string]> Script type. Use 'module' in order to load a Javascript ES6 module. See [script](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) for more details.
- returns: <[Promise]<[ElementHandle]>>
-Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload
-fires or when the script content was injected into frame.
+Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload fires or when the script content was injected into frame.
-Shortcut for main frame's [frame.addScriptTag(params)](#frameaddscripttagparams).
+Shortcut for main frame's [`frame.addScriptTag(params)`](#frameaddscripttagparams).
#### page.addStyleTag(params)
- `params` <[Object]>
@@ -1198,10 +1134,9 @@ Shortcut for main frame's [frame.addScriptTag(params)](#frameaddscripttagparams)
- `content` <[string]> Raw CSS content to be injected into frame.
- returns: <[Promise]<[ElementHandle]>>
-Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
-content. Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
+Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the content. Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
-Shortcut for main frame's [frame.addStyleTag(params)](#frameaddstyletagparams).
+Shortcut for main frame's [`frame.addStyleTag(params)`](#frameaddstyletagparams).
#### page.bringToFront()
- returns: <[Promise]>
@@ -1213,7 +1148,7 @@ Brings page to front (activates tab).
- `options` <[Object]>
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method checks an element matching `selector` by performing the following steps:
@@ -1225,10 +1160,9 @@ This method checks an element matching `selector` by performing the following st
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1. Ensure that the element is now checked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.check(selector[, options])](#framecheckselector-options).
+Shortcut for main frame's [`frame.check(selector[, options])`](#framecheckselector-options).
#### page.click(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
@@ -1242,7 +1176,7 @@ Shortcut for main frame's [frame.check(selector[, options])](#framecheckselector
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method clicks an element matching `selector` by performing the following steps:
@@ -1252,18 +1186,16 @@ This method clicks an element matching `selector` by performing the following st
1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.click(selector[, options])](#frameclickselector-options).
+Shortcut for main frame's [`frame.click(selector[, options])`](#frameclickselector-options).
#### page.close([options])
- `options` <[Object]>
- `runBeforeUnload` <[boolean]> Defaults to `false`. Whether to run the [before unload](https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload) page handlers.
- returns: <[Promise]>
-If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed. If
-`runBeforeUnload` is `true` the method will run unload handlers, but will **not** wait for the page to close.
+If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed. If `runBeforeUnload` is `true` the method will run unload handlers, but will **not** wait for the page to close.
By default, `page.close()` **does not** run `beforeunload` handlers.
@@ -1283,8 +1215,7 @@ Get the browser context that the page belongs to.
#### page.coverage
- returns: <[null]|[ChromiumCoverage]>
-Browser-specific Coverage implementation, only available for Chromium atm. See
-[ChromiumCoverage](#class-chromiumcoverage) for more details.
+Browser-specific Coverage implementation, only available for Chromium atm. See [ChromiumCoverage](#class-chromiumcoverage) for more details.
#### page.dblclick(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
@@ -1297,7 +1228,7 @@ Browser-specific Coverage implementation, only available for Chromium atm. See
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method double clicks an element matching `selector` by performing the following steps:
@@ -1307,31 +1238,27 @@ This method double clicks an element matching `selector` by performing the follo
1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
> **NOTE** `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
-Shortcut for main frame's [frame.dblclick(selector[, options])](#framedblclickselector-options).
+Shortcut for main frame's [`frame.dblclick(selector[, options])`](#framedblclickselector-options).
#### page.dispatchEvent(selector, type[, eventInit, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `type` <[string]> DOM event type: `"click"`, `"dragstart"`, etc.
- `eventInit` <[EvaluationArgument]> Optional event-specific initialization properties.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
-is dispatched. This is equivalend to calling
-[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
+The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click` is dispatched. This is equivalend to calling [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
```js
await page.dispatchEvent('button#submit', 'click');
```
-Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
-and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
+Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
* [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
@@ -1392,12 +1319,9 @@ await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').ma
Returns the value of the `pageFunction` invacation.
-If the function passed to the `page.evaluate` returns a [Promise], then `page.evaluate` would wait for the promise to
-resolve and return its value.
+If the function passed to the `page.evaluate` returns a [Promise], then `page.evaluate` would wait for the promise to resolve and return its value.
-If the function passed to the `page.evaluate` returns a non-[Serializable] value, then `page.evaluate` resolves to
-`undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`:
-`-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
+If the function passed to the `page.evaluate` returns a non-[Serializable] value, then `page.evaluate` resolves to `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
Passing argument to `pageFunction`:
@@ -1424,7 +1348,7 @@ const html = await page.evaluate(([body, suffix]) => body.innerHTML + suffix, [b
await bodyHandle.dispose();
```
-Shortcut for main frame's [frame.evaluate(pageFunction[, arg])](#frameevaluatepagefunction-arg).
+Shortcut for main frame's [`frame.evaluate(pageFunction[, arg])`](#frameevaluatepagefunction-arg).
#### page.evaluateHandle(pageFunction[, arg])
- `pageFunction` <[function]|[string]> Function to be evaluated in the page context
@@ -1433,11 +1357,9 @@ Shortcut for main frame's [frame.evaluate(pageFunction[, arg])](#frameevaluatepa
Returns the value of the `pageFunction` invacation as in-page object (JSHandle).
-The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page
-object (JSHandle).
+The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page object (JSHandle).
-If the function passed to the `page.evaluateHandle` returns a [Promise], then `page.evaluateHandle` would wait for the
-promise to resolve and return its value.
+If the function passed to the `page.evaluateHandle` returns a [Promise], then `page.evaluateHandle` would wait for the promise to resolve and return its value.
A string can also be passed in instead of a function:
@@ -1461,14 +1383,11 @@ await resultHandle.dispose();
- `handle` <[boolean]> Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is supported. When passing by value, multiple arguments are supported.
- returns: <[Promise]>
-The method adds a function called `name` on the `window` object of every frame in this page. When called, the function
-executes `playwrightBinding` and returns a [Promise] which resolves to the return value of `playwrightBinding`. If the
-`playwrightBinding` returns a [Promise], it will be awaited.
+The method adds a function called `name` on the `window` object of every frame in this page. When called, the function executes `playwrightBinding` and returns a [Promise] which resolves to the return value of `playwrightBinding`. If the `playwrightBinding` returns a [Promise], it will be awaited.
-The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext:
-BrowserContext, page: Page, frame: Frame }`.
+The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext: BrowserContext, page: Page, frame: Frame }`.
-See [browserContext.exposeBinding(name, playwrightBinding[, options])](#browsercontextexposebindingname-playwrightbinding-options) for the context-wide version.
+See [`browserContext.exposeBinding(name, playwrightBinding[, options])`](#browsercontextexposebindingname-playwrightbinding-options) for the context-wide version.
> **NOTE** Functions installed via `page.exposeBinding` survive navigations.
@@ -1515,12 +1434,11 @@ await page.setContent(`
- `playwrightFunction` <[function]> Callback function which will be called in Playwright's context.
- returns: <[Promise]>
-The method adds a function called `name` on the `window` object of every frame in the page. When called, the function
-executes `playwrightFunction` and returns a [Promise] which resolves to the return value of `playwrightFunction`.
+The method adds a function called `name` on the `window` object of every frame in the page. When called, the function executes `playwrightFunction` and returns a [Promise] which resolves to the return value of `playwrightFunction`.
If the `playwrightFunction` returns a [Promise], it will be awaited.
-See [browserContext.exposeFunction(name, playwrightFunction)](#browsercontextexposefunctionname-playwrightfunction) for context-wide exposed function.
+See [`browserContext.exposeFunction(name, playwrightFunction)`](#browsercontextexposefunctionname-playwrightfunction) for context-wide exposed function.
> **NOTE** Functions installed via `page.exposeFunction` survive navigations.
@@ -1581,28 +1499,24 @@ const fs = require('fs');
- `value` <[string]> Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
-element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`,
-`<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to
-clear the input field.
+This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to clear the input field.
-To send fine-grained keyboard events, use [page.type(selector, text[, options])](#pagetypeselector-text-options).
+To send fine-grained keyboard events, use [`page.type(selector, text[, options])`](#pagetypeselector-text-options).
-Shortcut for main frame's [frame.fill(selector, value[, options])](#framefillselector-value-options)
+Shortcut for main frame's [`frame.fill(selector, value[, options])`](#framefillselector-value-options)
#### page.focus(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
-waits until a matching element appears in the DOM.
+This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method waits until a matching element appears in the DOM.
-Shortcut for main frame's [frame.focus(selector[, options])](#framefocusselector-options).
+Shortcut for main frame's [`frame.focus(selector[, options])`](#framefocusselector-options).
#### page.frame(frameSelector)
- `frameSelector` <[string]|[Object]> Frame name or other frame lookup options.
@@ -1629,52 +1543,49 @@ An array of all frames attached to the page.
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `name` <[string]> Attribute name to get the value for.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[null]|[string]>>
Returns element attribute value.
#### page.goBack([options])
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
- returns: <[Promise]<[null]|[Response]>>
-Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
-last redirect. If can not go back, returns `null`.
+Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. If can not go back, returns `null`.
Navigate to the previous page in history.
#### page.goForward([options])
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
- returns: <[Promise]<[null]|[Response]>>
-Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
-last redirect. If can not go forward, returns `null`.
+Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. If can not go forward, returns `null`.
Navigate to the next page in history.
#### page.goto(url[, options])
- `url` <[string]> URL to navigate page to. The url should include scheme, e.g. `https://`.
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
- - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [page.setExtraHTTPHeaders(headers)](#pagesetextrahttpheadersheaders).
+ - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [`page.setExtraHTTPHeaders(headers)`](#pagesetextrahttpheadersheaders).
- returns: <[Promise]<[null]|[Response]>>
-Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
-last redirect.
+Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
`page.goto` will throw an error if:
* there's an SSL error (e.g. in case of self-signed certificates).
@@ -1683,16 +1594,12 @@ last redirect.
* the remote server does not respond or is unreachable.
* the main resource failed to load.
-`page.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
-Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
-[response.status()](#responsestatus).
+`page.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling [`response.status()`](#responsestatus).
-> **NOTE** `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
-`about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
-> **NOTE** Headless mode doesn't support navigation to a PDF document. See the [upstream
-issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
+> **NOTE** `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
+> **NOTE** Headless mode doesn't support navigation to a PDF document. See the [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
-Shortcut for main frame's [frame.goto(url[, options])](#framegotourl-options)
+Shortcut for main frame's [`frame.goto(url[, options])`](#framegotourl-options)
#### page.hover(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
@@ -1702,7 +1609,7 @@ Shortcut for main frame's [frame.goto(url[, options])](#framegotourl-options)
- `y` <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method hovers over an element matching `selector` by performing the following steps:
@@ -1712,15 +1619,14 @@ This method hovers over an element matching `selector` by performing the followi
1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.hover(selector[, options])](#framehoverselector-options).
+Shortcut for main frame's [`frame.hover(selector[, options])`](#framehoverselector-options).
#### page.innerHTML(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[string]>>
Returns `element.innerHTML`.
@@ -1728,7 +1634,7 @@ Returns `element.innerHTML`.
#### page.innerText(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[string]>>
Returns `element.innerText`.
@@ -1784,12 +1690,9 @@ Returns the PDF buffer.
> **NOTE** Generating a pdf is currently only supported in Chromium headless.
-`page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
-[page.emulateMedia(params)](#pageemulatemediaparams) before calling `page.pdf()`:
+`page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call [`page.emulateMedia(params)`](#pageemulatemediaparams) before calling `page.pdf()`:
-> **NOTE** By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
-[`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to
-force rendering of exact colors.
+> **NOTE** By default, `page.pdf()` generates a pdf with modified colors for printing. Use the [`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to force rendering of exact colors.
```js
// Generates a PDF with 'screen' media type.
@@ -1833,27 +1736,22 @@ The `format` options are:
- `options` <[Object]>
- `delay` <[number]> Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-Focuses the element, and then uses [keyboard.down(key)](#keyboarddownkey) and [keyboard.up(key)](#keyboardupkey).
+Focuses the element, and then uses [`keyboard.down(key)`](#keyboarddownkey) and [`keyboard.up(key)`](#keyboardupkey).
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
-[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
+`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the `key` values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
-`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
-`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
+`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
-Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
-modifier, modifier is pressed and being held while the subsequent key is being pressed.
+Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
```js
const page = await browser.newPage();
@@ -1869,15 +1767,14 @@ await browser.close();
#### page.reload([options])
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
- returns: <[Promise]<[null]|[Response]>>
-Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
-last redirect.
+Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
#### page.route(url, handler)
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
@@ -1908,8 +1805,7 @@ await page.goto('https://example.com');
await browser.close();
```
-Page routes take precedence over browser context routes (set up with [browserContext.route(url, handler)](#browsercontextrouteurl-handler)) when request matches
-both handlers.
+Page routes take precedence over browser context routes (set up with [`browserContext.route(url, handler)`](#browsercontextrouteurl-handler)) when request matches both handlers.
> **NOTE** Enabling routing disables http cache.
@@ -1925,13 +1821,12 @@ both handlers.
- `width` <[number]> width of clipping area
- `height` <[number]> height of clipping area
- `omitBackground` <[boolean]> Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[Buffer]>>
Returns the buffer with the captured screenshot.
-> **NOTE** Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for
-discussion.
+> **NOTE** Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for discussion.
#### page.selectOption(selector, values[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
@@ -1941,13 +1836,12 @@ discussion.
- `index` <[number]> Matches by the index.
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[Array]<[string]>>>
Returns the array of option values that have been successfully selected.
-Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
-matching `selector`, the method throws an error.
+Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element matching `selector`, the method throws an error.
```js
// single selection matching the value
@@ -1961,12 +1855,12 @@ page.selectOption('select#colors', ['red', 'green', 'blue']);
```
-Shortcut for main frame's [frame.selectOption(selector, values[, options])](#frameselectoptionselector-values-options)
+Shortcut for main frame's [`frame.selectOption(selector, values[, options])`](#frameselectoptionselector-values-options)
#### page.setContent(html[, options])
- `html` <[string]> HTML markup to assign to the page.
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
@@ -1977,22 +1871,21 @@ Shortcut for main frame's [frame.selectOption(selector, values[, options])](#fra
- `timeout` <[number]> Maximum navigation time in milliseconds
This setting will change the default maximum navigation time for the following methods and related shortcuts:
-* [page.goBack([options])](#pagegobackoptions)
-* [page.goForward([options])](#pagegoforwardoptions)
-* [page.goto(url[, options])](#pagegotourl-options)
-* [page.reload([options])](#pagereloadoptions)
-* [page.setContent(html[, options])](#pagesetcontenthtml-options)
-* [page.waitForNavigation([options])](#pagewaitfornavigationoptions)
+* [`page.goBack([options])`](#pagegobackoptions)
+* [`page.goForward([options])`](#pagegoforwardoptions)
+* [`page.goto(url[, options])`](#pagegotourl-options)
+* [`page.reload([options])`](#pagereloadoptions)
+* [`page.setContent(html[, options])`](#pagesetcontenthtml-options)
+* [`page.waitForNavigation([options])`](#pagewaitfornavigationoptions)
-> **NOTE** [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) takes priority over [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout),
-[browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) and [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout).
+> **NOTE** [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) takes priority over [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) and [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout).
#### page.setDefaultTimeout(timeout)
- `timeout` <[number]> Maximum time in milliseconds
This setting will change the default maximum time for all the methods accepting `timeout` option.
-> **NOTE** [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) takes priority over [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout).
+> **NOTE** [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) takes priority over [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout).
#### page.setExtraHTTPHeaders(headers)
- `headers` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
@@ -2010,14 +1903,12 @@ The extra HTTP headers will be sent with every request the page initiates.
- `buffer` <[Buffer]> File content **required**
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method expects `selector` to point to an [input
-element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
+This method expects `selector` to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
-Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
-are resolved relative to the the current working directory. For empty array, clears the selected files.
+Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they are resolved relative to the the current working directory. For empty array, clears the selected files.
#### page.setViewportSize(viewportSize)
- `viewportSize` <[Object]>
@@ -2025,11 +1916,9 @@ are resolved relative to the the current working directory. For empty array, cle
- `height` <[number]> page height in pixels. **required**
- returns: <[Promise]>
-In the case of multiple pages in a single browser, each page can have its own viewport size. However,
-[browser.newContext([options])](#browsernewcontextoptions) allows to set viewport size (and more) for all pages in the context at once.
+In the case of multiple pages in a single browser, each page can have its own viewport size. However, [`browser.newContext([options])`](#browsernewcontextoptions) allows to set viewport size (and more) for all pages in the context at once.
-`page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the
-viewport size before navigating to the page.
+`page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the viewport size before navigating to the page.
```js
const page = await browser.newPage();
@@ -2049,7 +1938,7 @@ await page.goto('https://example.com');
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method taps an element matching `selector` by performing the following steps:
@@ -2059,17 +1948,16 @@ This method taps an element matching `selector` by performing the following step
1. Use [page.touchscreen](#pagetouchscreen#pagetouchscreen) to tap the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
> **NOTE** `page.tap()` requires that the `hasTouch` option of the browser context be set to true.
-Shortcut for main frame's [frame.tap(selector[, options])](#frametapselector-options).
+Shortcut for main frame's [`frame.tap(selector[, options])`](#frametapselector-options).
#### page.textContent(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[null]|[string]>>
Returns `element.textContent`.
@@ -2077,7 +1965,7 @@ Returns `element.textContent`.
#### page.title()
- returns: <[Promise]<[string]>>
-Returns the page's title. Shortcut for main frame's [frame.title()](#frametitle).
+Returns the page's title. Shortcut for main frame's [`frame.title()`](#frametitle).
#### page.touchscreen
- returns: <[Touchscreen]>
@@ -2088,27 +1976,26 @@ Returns the page's title. Shortcut for main frame's [frame.title()](#frametitle)
- `options` <[Object]>
- `delay` <[number]> Time to wait between key presses in milliseconds. Defaults to 0.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send
-fine-grained keyboard events. To fill values in form fields, use [page.fill(selector, value[, options])](#pagefillselector-value-options).
+Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send fine-grained keyboard events. To fill values in form fields, use [`page.fill(selector, value[, options])`](#pagefillselector-value-options).
-To press a special key, like `Control` or `ArrowDown`, use [keyboard.press(key[, options])](#keyboardpresskey-options).
+To press a special key, like `Control` or `ArrowDown`, use [`keyboard.press(key[, options])`](#keyboardpresskey-options).
```js
await page.type('#mytextarea', 'Hello'); // Types instantly
await page.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
```
-Shortcut for main frame's [frame.type(selector, text[, options])](#frametypeselector-text-options).
+Shortcut for main frame's [`frame.type(selector, text[, options])`](#frametypeselector-text-options).
#### page.uncheck(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method unchecks an element matching `selector` by performing the following steps:
@@ -2120,22 +2007,21 @@ This method unchecks an element matching `selector` by performing the following
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1. Ensure that the element is now unchecked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
-Shortcut for main frame's [frame.uncheck(selector[, options])](#frameuncheckselector-options).
+Shortcut for main frame's [`frame.uncheck(selector[, options])`](#frameuncheckselector-options).
#### page.unroute(url[, handler])
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
- `handler` <[function]\([Route], [Request]\)> Optional handler function to route the request.
- returns: <[Promise]>
-Removes a route created with [page.route(url, handler)](#pagerouteurl-handler). When `handler` is not specified, removes all routes for the `url`.
+Removes a route created with [`page.route(url, handler)`](#pagerouteurl-handler). When `handler` is not specified, removes all routes for the `url`.
#### page.url()
- returns: <[string]>
-Shortcut for main frame's [frame.url()](#frameurl).
+Shortcut for main frame's [`frame.url()`](#frameurl).
#### page.video()
- returns: <[null]|[Video]>
@@ -2156,15 +2042,14 @@ Video object associated with this page.
Returns the event data value.
-Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
-value. Will throw an error if the page is closed before the event is fired.
+Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the page is closed before the event is fired.
#### page.waitForFunction(pageFunction[, arg, options])
- `pageFunction` <[function]|[string]> Function to be evaluated in browser context
- `arg` <[EvaluationArgument]> Optional argument to pass to `pageFunction`
- `options` <[Object]>
- `polling` <[number]|"raf"> If `polling` is `'raf'`, then `pageFunction` is constantly executed in `requestAnimationFrame` callback. If `polling` is a number, then it is treated as an interval in milliseconds at which the function would be executed. Defaults to `raf`.
- - `timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout).
+ - `timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout).
- returns: <[Promise]<[JSHandle]>>
Returns when the `pageFunction` returns a truthy value. It resolves to a JSHandle of the truthy value.
@@ -2191,7 +2076,7 @@ const selector = '.foo';
await page.waitForFunction(selector => !!document.querySelector(selector), selector);
```
-Shortcut for main frame's [frame.waitForFunction(pageFunction[, arg, options])](#framewaitforfunctionpagefunction-arg-options).
+Shortcut for main frame's [`frame.waitForFunction(pageFunction[, arg, options])`](#framewaitforfunctionpagefunction-arg-options).
#### page.waitForLoadState([state, options])
- `state` <"load"|"domcontentloaded"|"networkidle"> Load state to wait for, defaults to `load`. If the state has been already reached while loading current document, the method resolves immediately. Optional.
@@ -2199,13 +2084,12 @@ Shortcut for main frame's [frame.waitForFunction(pageFunction[, arg, options])](
- `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired.
- `'networkidle'` - wait until there are no network connections for at least `500` ms.
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
Returns when the required load state has been reached.
-This resolves when the page reaches a required load state, `load` by default. The navigation must have been committed
-when this method is called. If current document has already reached the required state, resolves immediately.
+This resolves when the page reaches a required load state, `load` by default. The navigation must have been committed when this method is called. If current document has already reached the required state, resolves immediately.
```js
await page.click('button'); // Click triggers navigation.
@@ -2221,11 +2105,11 @@ await popup.waitForLoadState('domcontentloaded'); // The promise resolves after
console.log(await popup.title()); // Popup is ready to use.
```
-Shortcut for main frame's [frame.waitForLoadState([state, options])](#framewaitforloadstatestate-options).
+Shortcut for main frame's [`frame.waitForLoadState([state, options])`](#framewaitforloadstatestate-options).
#### page.waitForNavigation([options])
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `url` <[string]|[RegExp]|[Function]> A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
@@ -2233,13 +2117,9 @@ Shortcut for main frame's [frame.waitForLoadState([state, options])](#framewaitf
- `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
- returns: <[Promise]<[null]|[Response]>>
-Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
-last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
-resolve with `null`.
+Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with `null`.
-This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly
-cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`.
-Consider this example:
+This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`. Consider this example:
```js
const [response] = await Promise.all([
@@ -2248,15 +2128,14 @@ const [response] = await Promise.all([
]);
```
-**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
-considered a navigation.
+**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.
-Shortcut for main frame's [frame.waitForNavigation([options])](#framewaitfornavigationoptions).
+Shortcut for main frame's [`frame.waitForNavigation([options])`](#framewaitfornavigationoptions).
#### page.waitForRequest(urlOrPredicate[, options])
- `urlOrPredicate` <[string]|[RegExp]|[Function]> Request URL string, regex or predicate receiving [Request] object.
- `options` <[Object]>
- - `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
+ - `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) method.
- returns: <[Promise]<[Request]>>
Waits for the matching request and returns it.
@@ -2274,7 +2153,7 @@ await page.waitForRequest(request => request.url().searchParams.get('foo') === '
#### page.waitForResponse(urlOrPredicate[, options])
- `urlOrPredicate` <[string]|[RegExp]|[function]\([Response]\):[boolean]> Request URL string, regex or predicate receiving [Response] object.
- `options` <[Object]>
- - `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[Response]>>
Returns the matched response.
@@ -2293,15 +2172,12 @@ return finalResponse.ok();
- `'detached'` - wait for element to not be present in DOM.
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible.
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`. This is opposite to the `'visible'` option.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[null]|[ElementHandle]>>
-Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
-`detached`.
+Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
-Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
-the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
-selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
+Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
This method works across navigations:
@@ -2328,28 +2204,25 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
Waits for the given `timeout` in milliseconds.
-Note that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be
-flaky. Use signals such as network events, selectors becoming visible and others instead.
+Note that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be flaky. Use signals such as network events, selectors becoming visible and others instead.
```js
// wait for 1 second
await page.waitForTimeout(1000);
```
-Shortcut for main frame's [frame.waitForTimeout(timeout)](#framewaitfortimeouttimeout).
+Shortcut for main frame's [`frame.waitForTimeout(timeout)`](#framewaitfortimeouttimeout).
#### page.workers()
- returns: <[Array]<[Worker]>>
-This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
-associated with the page.
+This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) associated with the page.
> **NOTE** This does not contain ServiceWorkers
### class: Frame
-At every point of time, page exposes its current frame tree via the [page.mainFrame()](#pagemainframe) and [frame.childFrames()](#framechildframes)
-methods.
+At every point of time, page exposes its current frame tree via the [`page.mainFrame()`](#pagemainframe) and [`frame.childFrames()`](#framechildframes) methods.
[Frame] object's lifecycle is controlled by three events, dispatched on the page object:
- [page.on('frameattached')](#pageonframeattached) - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
@@ -2435,8 +2308,7 @@ console.log(text);
Returns the ElementHandle pointing to the frame element.
-The method finds an element matching the specified selector within the frame. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns `null`.
+The method finds an element matching the specified selector within the frame. See [Working with selectors](#working-with-selectors) for more details. If no elements match the selector, returns `null`.
#### frame.$$(selector)
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -2444,8 +2316,7 @@ selectors](#working-with-selectors) for more details. If no elements match the s
Returns the ElementHandles pointing to the frame elements.
-The method finds all elements matching the specified selector within the frame. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns empty array.
+The method finds all elements matching the specified selector within the frame. See [Working with selectors](#working-with-selectors) for more details. If no elements match the selector, returns empty array.
#### frame.$eval(selector, pageFunction[, arg])
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -2455,9 +2326,7 @@ selectors](#working-with-selectors) for more details. If no elements match the s
Returns the return value of `pageFunction`
-The method finds an element matching the specified selector within the frame and passes it as a first argument to
-`pageFunction`. See [Working with selectors](#working-with-selectors) for more details. If no elements match the
-selector, the method throws an error.
+The method finds an element matching the specified selector within the frame and passes it as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details. If no elements match the selector, the method throws an error.
If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
@@ -2477,8 +2346,7 @@ const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + s
Returns the return value of `pageFunction`
-The method finds all elements matching the specified selector within the frame and passes an array of matched elements
-as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details.
+The method finds all elements matching the specified selector within the frame and passes an array of matched elements as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details.
If `pageFunction` returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return its value.
@@ -2509,15 +2377,14 @@ Adds a `<script>` tag into the page with the desired url or content.
Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
-Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
-content.
+Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the content.
#### frame.check(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method checks an element matching `selector` by performing the following steps:
@@ -2529,8 +2396,7 @@ This method checks an element matching `selector` by performing the following st
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1. Ensure that the element is now checked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### frame.childFrames()
- returns: <[Array]<[Frame]>>
@@ -2547,7 +2413,7 @@ Passing zero timeout disables this.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method clicks an element matching `selector` by performing the following steps:
@@ -2557,8 +2423,7 @@ This method clicks an element matching `selector` by performing the following st
1. Use [page.mouse](#pagemouse) to click in the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### frame.content()
- returns: <[Promise]<[string]>>
@@ -2576,7 +2441,7 @@ Gets the full HTML contents of the frame, including the doctype.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method double clicks an element matching `selector` by performing the following steps:
@@ -2586,8 +2451,7 @@ This method double clicks an element matching `selector` by performing the follo
1. Use [page.mouse](#pagemouse) to double click in the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
> **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
@@ -2596,19 +2460,16 @@ Passing zero timeout disables this.
- `type` <[string]> DOM event type: `"click"`, `"dragstart"`, etc.
- `eventInit` <[EvaluationArgument]> Optional event-specific initialization properties.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
-is dispatched. This is equivalend to calling
-[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
+The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click` is dispatched. This is equivalend to calling [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
```js
await frame.dispatchEvent('button#submit', 'click');
```
-Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
-and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
+Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
* [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
@@ -2634,12 +2495,9 @@ await frame.dispatchEvent('#source', 'dragstart', { dataTransfer });
Returns the return value of `pageFunction`
-If the function passed to the `frame.evaluate` returns a [Promise], then `frame.evaluate` would wait for the promise to
-resolve and return its value.
+If the function passed to the `frame.evaluate` returns a [Promise], then `frame.evaluate` would wait for the promise to resolve and return its value.
-If the function passed to the `frame.evaluate` returns a non-[Serializable] value, then `frame.evaluate` returns
-`undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`:
-`-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
+If the function passed to the `frame.evaluate` returns a non-[Serializable] value, then `frame.evaluate` returns `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
```js
const result = await frame.evaluate(([x, y]) => {
@@ -2669,11 +2527,9 @@ await bodyHandle.dispose();
Returns the return value of `pageFunction` as in-page object (JSHandle).
-The only difference between `frame.evaluate` and `frame.evaluateHandle` is that `frame.evaluateHandle` returns in-page
-object (JSHandle).
+The only difference between `frame.evaluate` and `frame.evaluateHandle` is that `frame.evaluateHandle` returns in-page object (JSHandle).
-If the function, passed to the `frame.evaluateHandle`, returns a [Promise], then `frame.evaluateHandle` would wait for
-the promise to resolve and return its value.
+If the function, passed to the `frame.evaluateHandle`, returns a [Promise], then `frame.evaluateHandle` would wait for the promise to resolve and return its value.
```js
const aWindowHandle = await frame.evaluateHandle(() => Promise.resolve(window));
@@ -2700,31 +2556,27 @@ await resultHandle.dispose();
- `value` <[string]> Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
-element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`,
-`<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to
-clear the input field.
+This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. If the element matching `selector` is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to clear the input field.
-To send fine-grained keyboard events, use [frame.type(selector, text[, options])](#frametypeselector-text-options).
+To send fine-grained keyboard events, use [`frame.type(selector, text[, options])`](#frametypeselector-text-options).
#### frame.focus(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
-waits until a matching element appears in the DOM.
+This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method waits until a matching element appears in the DOM.
#### frame.frameElement()
- returns: <[Promise]<[ElementHandle]>>
Returns the `frame` or `iframe` element handle which corresponds to this frame.
-This is an inverse of [elementHandle.contentFrame()](#elementhandlecontentframe). Note that returned handle actually belongs to the parent frame.
+This is an inverse of [`elementHandle.contentFrame()`](#elementhandlecontentframe). Note that returned handle actually belongs to the parent frame.
This method throws an error if the frame has been detached before `frameElement()` returns.
@@ -2738,7 +2590,7 @@ console.log(frame === contentFrame); // -> true
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `name` <[string]> Attribute name to get the value for.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[null]|[string]>>
Returns element attribute value.
@@ -2746,16 +2598,15 @@ Returns element attribute value.
#### frame.goto(url[, options])
- `url` <[string]> URL to navigate frame to. The url should include scheme, e.g. `https://`.
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
- - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [page.setExtraHTTPHeaders(headers)](#pagesetextrahttpheadersheaders).
+ - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [`page.setExtraHTTPHeaders(headers)`](#pagesetextrahttpheadersheaders).
- returns: <[Promise]<[null]|[Response]>>
-Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
-last redirect.
+Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
`frame.goto` will throw an error if:
* there's an SSL error (e.g. in case of self-signed certificates).
@@ -2764,14 +2615,10 @@ last redirect.
* the remote server does not respond or is unreachable.
* the main resource failed to load.
-`frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404
-"Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
-[response.status()](#responsestatus).
+`frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling [`response.status()`](#responsestatus).
-> **NOTE** `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation
-to `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
-> **NOTE** Headless mode doesn't support navigation to a PDF document. See the [upstream
-issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
+> **NOTE** `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation to `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
+> **NOTE** Headless mode doesn't support navigation to a PDF document. See the [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
#### frame.hover(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
@@ -2781,7 +2628,7 @@ issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
- `y` <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method hovers over an element matching `selector` by performing the following steps:
@@ -2791,13 +2638,12 @@ This method hovers over an element matching `selector` by performing the followi
1. Use [page.mouse](#pagemouse) to hover over the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### frame.innerHTML(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[string]>>
Returns `element.innerHTML`.
@@ -2805,7 +2651,7 @@ Returns `element.innerHTML`.
#### frame.innerText(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[string]>>
Returns `element.innerText`.
@@ -2822,8 +2668,7 @@ Returns frame's name attribute as specified in the tag.
If the name is empty, returns the id attribute instead.
-> **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed
-later.
+> **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed later.
#### frame.page()
- returns: <[Page]>
@@ -2841,25 +2686,20 @@ Parent frame, if any. Detached frames and main frames return `null`.
- `options` <[Object]>
- `delay` <[number]> Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
-[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
+`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the `key` values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
-`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
-`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
+`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
-Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
-modifier, modifier is pressed and being held while the subsequent key is being pressed.
+Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
#### frame.selectOption(selector, values[, options])
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -2869,13 +2709,12 @@ modifier, modifier is pressed and being held while the subsequent key is being p
- `index` <[number]> Matches by the index.
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[Array]<[string]>>>
Returns the array of option values that have been successfully selected.
-Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
-matching `selector`, the method throws an error.
+Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element matching `selector`, the method throws an error.
```js
// single selection matching the value
@@ -2891,7 +2730,7 @@ frame.selectOption('select#colors', 'red', 'green', 'blue');
#### frame.setContent(html[, options])
- `html` <[string]> HTML markup to assign to the page.
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
@@ -2906,14 +2745,12 @@ frame.selectOption('select#colors', 'red', 'green', 'blue');
- `buffer` <[Buffer]> File content **required**
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method expects `selector` to point to an [input
-element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
+This method expects `selector` to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
-Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
-are resolved relative to the the current working directory. For empty array, clears the selected files.
+Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they are resolved relative to the the current working directory. For empty array, clears the selected files.
#### frame.tap(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
@@ -2924,7 +2761,7 @@ are resolved relative to the the current working directory. For empty array, cle
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method taps an element matching `selector` by performing the following steps:
@@ -2934,15 +2771,14 @@ This method taps an element matching `selector` by performing the following step
1. Use [page.touchscreen](#pagetouchscreen#pagetouchscreen) to tap the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
> **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
#### frame.textContent(selector[, options])
- `selector` <[string]> A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](#working-with-selectors) for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[null]|[string]>>
Returns `element.textContent`.
@@ -2958,13 +2794,12 @@ Returns the page title.
- `options` <[Object]>
- `delay` <[number]> Time to wait between key presses in milliseconds. Defaults to 0.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
-send fine-grained keyboard events. To fill values in form fields, use [frame.fill(selector, value[, options])](#framefillselector-value-options).
+Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to send fine-grained keyboard events. To fill values in form fields, use [`frame.fill(selector, value[, options])`](#framefillselector-value-options).
-To press a special key, like `Control` or `ArrowDown`, use [keyboard.press(key[, options])](#keyboardpresskey-options).
+To press a special key, like `Control` or `ArrowDown`, use [`keyboard.press(key[, options])`](#keyboardpresskey-options).
```js
await frame.type('#mytextarea', 'Hello'); // Types instantly
@@ -2976,7 +2811,7 @@ await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a
- `options` <[Object]>
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method checks an element matching `selector` by performing the following steps:
@@ -2988,8 +2823,7 @@ This method checks an element matching `selector` by performing the following st
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1. Ensure that the element is now unchecked. If not, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### frame.url()
- returns: <[string]>
@@ -3001,7 +2835,7 @@ Returns frame's url.
- `arg` <[EvaluationArgument]> Optional argument to pass to `pageFunction`
- `options` <[Object]>
- `polling` <[number]|"raf"> If `polling` is `'raf'`, then `pageFunction` is constantly executed in `requestAnimationFrame` callback. If `polling` is a number, then it is treated as an interval in milliseconds at which the function would be executed. Defaults to `raf`.
- - `timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout).
+ - `timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout).
- returns: <[Promise]<[JSHandle]>>
Returns when the `pageFunction` returns a truthy value, returns that value.
@@ -3034,13 +2868,12 @@ await frame.waitForFunction(selector => !!document.querySelector(selector), sele
- `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired.
- `'networkidle'` - wait until there are no network connections for at least `500` ms.
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
Waits for the required load state to be reached.
-This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed
-when this method is called. If current document has already reached the required state, resolves immediately.
+This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed when this method is called. If current document has already reached the required state, resolves immediately.
```js
await frame.click('button'); // Click triggers navigation.
@@ -3049,7 +2882,7 @@ await frame.waitForLoadState(); // Waits for 'load' state by default.
#### frame.waitForNavigation([options])
- `options` <[Object]>
- - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultNavigationTimeout(timeout)`](#browsercontextsetdefaultnavigationtimeouttimeout), [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout), [`page.setDefaultNavigationTimeout(timeout)`](#pagesetdefaultnavigationtimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- `url` <[string]|[RegExp]|[Function]> URL string, URL regex pattern or predicate receiving [URL] to match while waiting for the navigation.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle"> When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
@@ -3057,12 +2890,9 @@ await frame.waitForLoadState(); // Waits for 'load' state by default.
- `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
- returns: <[Promise]<[null]|[Response]>>
-Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
-last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
-resolve with `null`.
+Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with `null`.
-This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
-the frame to navigate. Consider this example:
+This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause the frame to navigate. Consider this example:
```js
const [response] = await Promise.all([
@@ -3071,8 +2901,7 @@ const [response] = await Promise.all([
]);
```
-**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
-considered a navigation.
+**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.
#### frame.waitForSelector(selector[, options])
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -3082,15 +2911,12 @@ considered a navigation.
- `'detached'` - wait for element to not be present in DOM.
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible.
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`. This is opposite to the `'visible'` option.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[null]|[ElementHandle]>>
-Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
-`detached`.
+Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
-Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
-the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
-selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
+Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
This method works across navigations:
@@ -3117,13 +2943,12 @@ const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
Waits for the given `timeout` in milliseconds.
-Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
-be flaky. Use signals such as network events, selectors becoming visible and others instead.
+Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be flaky. Use signals such as network events, selectors becoming visible and others instead.
### class: ElementHandle
* extends: [JSHandle]
-ElementHandle represents an in-page DOM element. ElementHandles can be created with the [page.$(selector)](#pageselector) method.
+ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`page.$(selector)`](#pageselector) method.
```js
const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
@@ -3138,10 +2963,9 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-ElementHandle prevents DOM element from garbage collection unless the handle is disposed with [jsHandle.dispose()](#jshandledispose).
-ElementHandles are auto-disposed when their origin frame gets navigated.
+ElementHandle prevents DOM element from garbage collection unless the handle is disposed with [`jsHandle.dispose()`](#jshandledispose). ElementHandles are auto-disposed when their origin frame gets navigated.
-ElementHandle instances can be used as an argument in [page.$eval(selector, pageFunction[, arg])](#pageevalselector-pagefunction-arg) and [page.evaluate(pageFunction[, arg])](#pageevaluatepagefunction-arg) methods.
+ElementHandle instances can be used as an argument in [`page.$eval(selector, pageFunction[, arg])`](#pageevalselector-pagefunction-arg) and [`page.evaluate(pageFunction[, arg])`](#pageevaluatepagefunction-arg) methods.
<!-- GEN:toc -->
- [elementHandle.$(selector)](#elementhandleselector)
@@ -3190,15 +3014,13 @@ ElementHandle instances can be used as an argument in [page.$eval(selector, page
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
- returns: <[Promise]<[null]|[ElementHandle]>>
-The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns `null`.
+The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See [Working with selectors](#working-with-selectors) for more details. If no elements match the selector, returns `null`.
#### elementHandle.$$(selector)
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
- returns: <[Promise]<[Array]<[ElementHandle]>>>
-The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns empty array.
+The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See [Working with selectors](#working-with-selectors) for more details. If no elements match the selector, returns empty array.
#### elementHandle.$eval(selector, pageFunction[, arg])
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -3208,9 +3030,7 @@ selectors](#working-with-selectors) for more details. If no elements match the s
Returns the return value of `pageFunction`
-The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
-argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details. If no elements match
-the selector, the method throws an error.
+The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details. If no elements match the selector, the method throws an error.
If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
@@ -3230,9 +3050,7 @@ expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
Returns the return value of `pageFunction`
-The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
-matched elements as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more
-details.
+The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of matched elements as a first argument to `pageFunction`. See [Working with selectors](#working-with-selectors) for more details.
If `pageFunction` returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return its value.
@@ -3257,18 +3075,13 @@ expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).
- width <[number]> the width of the element in pixels.
- height <[number]> the height of the element in pixels.
-This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
-calculated relative to the main frame viewport - which is usually the same as the browser window.
+This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is calculated relative to the main frame viewport - which is usually the same as the browser window.
-Scrolling affects the returned bonding box, similarly to
-[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
-means `x` and/or `y` may be negative.
+Scrolling affects the returned bonding box, similarly to [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That means `x` and/or `y` may be negative.
-Elements from child frames return the bounding box relative to the main frame, unlike the
-[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
+Elements from child frames return the bounding box relative to the main frame, unlike the [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
-Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
-snippet should click the center of the element.
+Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following snippet should click the center of the element.
```js
const box = await elementHandle.boundingBox();
@@ -3279,7 +3092,7 @@ await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
- `options` <[Object]>
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method checks the element by performing the following steps:
@@ -3292,8 +3105,7 @@ This method checks the element by performing the following steps:
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### elementHandle.click([options])
- `options` <[Object]>
@@ -3306,7 +3118,7 @@ Passing zero timeout disables this.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method clicks the element by performing the following steps:
@@ -3317,8 +3129,7 @@ This method clicks the element by performing the following steps:
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### elementHandle.contentFrame()
- returns: <[Promise]<[null]|[Frame]>>
@@ -3335,7 +3146,7 @@ Returns the content frame for element handles referencing iframe nodes, or `null
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method double clicks the element by performing the following steps:
@@ -3346,8 +3157,7 @@ This method double clicks the element by performing the following steps:
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
> **NOTE** `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
@@ -3356,16 +3166,13 @@ Passing zero timeout disables this.
- `eventInit` <[EvaluationArgument]> Optional event-specific initialization properties.
- returns: <[Promise]>
-The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
-is dispatched. This is equivalend to calling
-[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
+The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click` is dispatched. This is equivalend to calling [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
```js
await elementHandle.dispatchEvent('click');
```
-Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
-and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
+Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
* [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
@@ -3388,12 +3195,10 @@ await elementHandle.dispatchEvent('dragstart', { dataTransfer });
- `value` <[string]> Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element.
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input`
-event after filling. If the element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws
-an error. Note that you can pass an empty string to clear the input field.
+This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. If the element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to clear the input field.
#### elementHandle.focus()
- returns: <[Promise]>
@@ -3413,7 +3218,7 @@ Returns element attribute value.
- `y` <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method hovers over the element by performing the following steps:
@@ -3424,8 +3229,7 @@ This method hovers over the element by performing the following steps:
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### elementHandle.innerHTML()
- returns: <[Promise]<[string]>>
@@ -3447,27 +3251,22 @@ Returns the frame containing the given element.
- `options` <[Object]>
- `delay` <[number]> Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-Focuses the element, and then uses [keyboard.down(key)](#keyboarddownkey) and [keyboard.up(key)](#keyboardupkey).
+Focuses the element, and then uses [`keyboard.down(key)`](#keyboarddownkey) and [`keyboard.up(key)`](#keyboardupkey).
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
-[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
+`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the `key` values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
-`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
-`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
+`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
-Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
-modifier, modifier is pressed and being held while the subsequent key is being pressed.
+Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
#### elementHandle.screenshot([options])
- `options` <[Object]>
@@ -3475,25 +3274,21 @@ modifier, modifier is pressed and being held while the subsequent key is being p
- `type` <"png"|"jpeg"> Specify screenshot type, defaults to `png`.
- `quality` <[number]> The quality of the image, between 0-100. Not applicable to `png` images.
- `omitBackground` <[boolean]> Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[Buffer]>>
Returns the buffer with the captured screenshot.
-This method waits for the [actionability](./actionability.md) checks, then scrolls element into view before taking a
-screenshot. If the element is detached from DOM, the method throws an error.
+This method waits for the [actionability](./actionability.md) checks, then scrolls element into view before taking a screenshot. If the element is detached from DOM, the method throws an error.
#### elementHandle.scrollIntoViewIfNeeded([options])
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method waits for [actionability](./actionability.md) checks, then tries to scroll element into view, unless it is
-completely visible as defined by
-[IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s ```ratio```.
+This method waits for [actionability](./actionability.md) checks, then tries to scroll element into view, unless it is completely visible as defined by [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s ```ratio```.
-Throws when ```elementHandle``` does not point to an element
-[connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
+Throws when ```elementHandle``` does not point to an element [connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
#### elementHandle.selectOption(values[, options])
- `values` <[null]|[string]|[ElementHandle]|[Array]<[string]>|[Object]|[Array]<[ElementHandle]>|[Array]<[Object]>> Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are equivalent to `{value:'string'}`. Option is considered matching if all specified properties match.
@@ -3502,13 +3297,12 @@ Throws when ```elementHandle``` does not point to an element
- `index` <[number]> Matches by the index.
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[Array]<[string]>>>
Returns the array of option values that have been successfully selected.
-Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>`
-element, the method throws an error.
+Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>` element, the method throws an error.
```js
// single selection matching the value
@@ -3526,11 +3320,10 @@ handle.selectOption({ value: 'blue' }, { index: 2 }, 'red');
#### elementHandle.selectText([options])
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method waits for [actionability](./actionability.md) checks, then focuses the element and selects all its text
-content.
+This method waits for [actionability](./actionability.md) checks, then focuses the element and selects all its text content.
#### elementHandle.setInputFiles(files[, options])
- `files` <[string]|[Array]<[string]>|[Object]|[Array]<[Object]>>
@@ -3539,14 +3332,12 @@ content.
- `buffer` <[Buffer]> File content **required**
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-This method expects `elementHandle` to point to an [input
-element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
+This method expects `elementHandle` to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
-Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
-are resolved relative to the the current working directory. For empty array, clears the selected files.
+Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they are resolved relative to the the current working directory. For empty array, clears the selected files.
#### elementHandle.tap([options])
- `options` <[Object]>
@@ -3556,7 +3347,7 @@ are resolved relative to the the current working directory. For empty array, cle
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method taps the element by performing the following steps:
@@ -3567,8 +3358,7 @@ This method taps the element by performing the following steps:
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
> **NOTE** `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
@@ -3585,12 +3375,12 @@ Returns the `node.textContent`.
- `options` <[Object]>
- `delay` <[number]> Time to wait between key presses in milliseconds. Defaults to 0.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
-To press a special key, like `Control` or `ArrowDown`, use [elementHandle.press(key[, options])](#elementhandlepresskey-options).
+To press a special key, like `Control` or `ArrowDown`, use [`elementHandle.press(key[, options])`](#elementhandlepresskey-options).
```js
await elementHandle.type('Hello'); // Types instantly
@@ -3609,7 +3399,7 @@ await elementHandle.press('Enter');
- `options` <[Object]>
- `force` <[boolean]> Whether to bypass the [actionability](./actionability.md) checks. Defaults to `false`.
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
This method checks the element by performing the following steps:
@@ -3622,19 +3412,17 @@ This method checks the element by performing the following steps:
If the element is detached from the DOM at any moment during the action, this method rejects.
-When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
-Passing zero timeout disables this.
+When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError]. Passing zero timeout disables this.
#### elementHandle.waitForElementState(state[, options])
- `state` <"visible"|"hidden"|"stable"|"enabled"|"disabled"> A state to wait for, see below for more details.
- `options` <[Object]>
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
Returns the element satisfies the `state`.
-Depending on the `state` parameter, this method waits for one of the [actionability](./actionability.md) checks to pass.
-This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
+Depending on the `state` parameter, this method waits for one of the [actionability](./actionability.md) checks to pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
* `"visible"` Wait until the element is [visible](./actionability.md#visible).
* `"hidden"` Wait until the element is [not visible](./actionability.md#visible) or [not attached](./actionability.md#attached). Note that waiting for hidden does not throw when the element detaches.
* `"stable"` Wait until the element is both [visible](./actionability.md#visible) and [stable](./actionability.md#stable).
@@ -3651,15 +3439,12 @@ If the element does not satisfy the condition for the `timeout` milliseconds, th
- `'detached'` - wait for element to not be present in DOM.
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible.
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`. This is opposite to the `'visible'` option.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]<[null]|[ElementHandle]>>
Returns element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
-Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or
-become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
-will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will
-throw.
+Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
```js
await page.setContent(`<div><span></span></div>`);
@@ -3668,23 +3453,20 @@ const div = await page.$('div');
const span = await div.waitForSelector('span', { state: 'attached' });
```
-> **NOTE** This method does not work across navigations, use [page.waitForSelector(selector[, options])](#pagewaitforselectorselector-options) instead.
+> **NOTE** This method does not work across navigations, use [`page.waitForSelector(selector[, options])`](#pagewaitforselectorselector-options) instead.
### class: JSHandle
-JSHandle represents an in-page JavaScript object. JSHandles can be created with the [page.evaluateHandle(pageFunction[, arg])](#pageevaluatehandlepagefunction-arg) method.
+JSHandle represents an in-page JavaScript object. JSHandles can be created with the [`page.evaluateHandle(pageFunction[, arg])`](#pageevaluatehandlepagefunction-arg) method.
```js
const windowHandle = await page.evaluateHandle(() => window);
// ...
```
-JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with
-[jsHandle.dispose()](#jshandledispose). JSHandles are auto-disposed when their origin frame gets navigated or the parent context gets
-destroyed.
+JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with [`jsHandle.dispose()`](#jshandledispose). JSHandles are auto-disposed when their origin frame gets navigated or the parent context gets destroyed.
-JSHandle instances can be used as an argument in [page.$eval(selector, pageFunction[, arg])](#pageevalselector-pagefunction-arg), [page.evaluate(pageFunction[, arg])](#pageevaluatepagefunction-arg) and [page.evaluateHandle(pageFunction[, arg])](#pageevaluatehandlepagefunction-arg)
-methods.
+JSHandle instances can be used as an argument in [`page.$eval(selector, pageFunction[, arg])`](#pageevalselector-pagefunction-arg), [`page.evaluate(pageFunction[, arg])`](#pageevaluatepagefunction-arg) and [`page.evaluateHandle(pageFunction[, arg])`](#pageevaluatehandlepagefunction-arg) methods.
<!-- GEN:toc -->
- [jsHandle.asElement()](#jshandleaselement)
@@ -3715,8 +3497,7 @@ Returns the return value of `pageFunction`
This method passes this handle as the first argument to `pageFunction`.
-If `pageFunction` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its
-value.
+If `pageFunction` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its value.
Examples:
@@ -3734,13 +3515,11 @@ Returns the return value of `pageFunction` as in-page object (JSHandle).
This method passes this handle as the first argument to `pageFunction`.
-The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns
-in-page object (JSHandle).
+The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns in-page object (JSHandle).
-If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait
-for the promise to resolve and return its value.
+If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait for the promise to resolve and return its value.
-See [page.evaluateHandle(pageFunction[, arg])](#pageevaluatehandlepagefunction-arg) for more details.
+See [`page.evaluateHandle(pageFunction[, arg])`](#pageevaluatehandlepagefunction-arg) for more details.
#### jsHandle.getProperties()
- returns: <[Promise]<[Map]<[string], [JSHandle]>>>
@@ -3764,12 +3543,9 @@ Fetches a single property from the referenced object.
#### jsHandle.jsonValue()
- returns: <[Promise]<[Serializable]>>
-Returns a JSON representation of the object. If the object has a
-[`toJSON`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior)
-function, it **will not be called**.
+Returns a JSON representation of the object. If the object has a [`toJSON`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior) function, it **will not be called**.
-> **NOTE** The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
-error if the object has circular references.
+> **NOTE** The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the object has circular references.
### class: ConsoleMessage
@@ -3797,9 +3573,7 @@ error if the object has circular references.
#### consoleMessage.type()
- returns: <[string]>
-One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
-`'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`, `'profileEnd'`,
-`'count'`, `'timeEnd'`.
+One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`, `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`, `'profileEnd'`, `'count'`, `'timeEnd'`.
### class: Dialog
@@ -3860,8 +3634,7 @@ Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prom
[Download] objects are dispatched by page via the [page.on('download')](#pageondownload) event.
-All the downloaded files belonging to the browser context are deleted when the browser context is closed. All downloaded
-files are deleted when the browser closes.
+All the downloaded files belonging to the browser context are deleted when the browser context is closed. All downloaded files are deleted when the browser closes.
Download event is emitted once the download starts. Download path becomes available once download completes:
@@ -3875,9 +3648,7 @@ const path = await download.path();
...
```
-> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
-downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
-download is not performed and user has no access to the downloaded files.
+> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.
<!-- GEN:toc -->
- [download.createReadStream()](#downloadcreatereadstream)
@@ -3918,10 +3689,7 @@ Saves the download to a user-specified path.
#### download.suggestedFilename()
- returns: <[string]>
-Returns suggested filename for this download. It is typically computed by the browser from the
-[`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) response header
-or the `download` attribute. See the spec on [whatwg](https://html.spec.whatwg.org/#downloading-resources). Different
-browsers can use different logic for computing it.
+Returns suggested filename for this download. It is typically computed by the browser from the [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) response header or the `download` attribute. See the spec on [whatwg](https://html.spec.whatwg.org/#downloading-resources). Different browsers can use different logic for computing it.
#### download.url()
- returns: <[string]>
@@ -3943,8 +3711,7 @@ console.log(await page.video().path());
#### video.path()
- returns: <[Promise]<[string]>>
-Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem
-upon closing the browser context.
+Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem upon closing the browser context.
### class: FileChooser
@@ -3985,19 +3752,16 @@ Returns page this file chooser belongs to.
- `buffer` <[Buffer]> File content **required**
- `options` <[Object]>
- `noWaitAfter` <[boolean]> Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.
- - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
+ - `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [`browserContext.setDefaultTimeout(timeout)`](#browsercontextsetdefaulttimeouttimeout) or [`page.setDefaultTimeout(timeout)`](#pagesetdefaulttimeouttimeout) methods.
- returns: <[Promise]>
-Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then
-they are resolved relative to the the current working directory. For empty array, clears the selected files.
+Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then they are resolved relative to the the current working directory. For empty array, clears the selected files.
### class: Keyboard
-Keyboard provides an api for managing a virtual keyboard. The high level api is [keyboard.type(text[, options])](#keyboardtypetext-options), which takes raw
-characters and generates proper keydown, keypress/input, and keyup events on your page.
+Keyboard provides an api for managing a virtual keyboard. The high level api is [`keyboard.type(text[, options])`](#keyboardtypetext-options), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
-For finer control, you can use [keyboard.down(key)](#keyboarddownkey), [keyboard.up(key)](#keyboardupkey), and [keyboard.insertText(text)](#keyboardinserttexttext) to manually fire
-events as if they were generated from a real keyboard.
+For finer control, you can use [`keyboard.down(key)`](#keyboarddownkey), [`keyboard.up(key)`](#keyboardupkey), and [`keyboard.insertText(text)`](#keyboardinserttexttext) to manually fire events as if they were generated from a real keyboard.
An example of holding down `Shift` in order to select and delete some text:
@@ -4045,26 +3809,19 @@ await page.keyboard.press('Meta+A');
Dispatches a `keydown` event.
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
-[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
+`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the `key` values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
-`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
-`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
+`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
-If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier
-active. To release the modifier key, use [keyboard.up(key)](#keyboardupkey).
+If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier active. To release the modifier key, use [`keyboard.up(key)`](#keyboardupkey).
-After the key is pressed once, subsequent calls to [keyboard.down(key)](#keyboarddownkey) will have
-[repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
-[keyboard.up(key)](#keyboardupkey).
+After the key is pressed once, subsequent calls to [`keyboard.down(key)`](#keyboarddownkey) will have [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use [`keyboard.up(key)`](#keyboardupkey).
> **NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
@@ -4086,22 +3843,17 @@ page.keyboard.insertText('嗨');
- `delay` <[number]> Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- returns: <[Promise]>
-`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
-value or a single character to generate the text for. A superset of the `key` values can be found
-[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
+`key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the `key` values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
-`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
-`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
+`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
-If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
-texts.
+If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
-Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the
-modifier, modifier is pressed and being held while the subsequent key is being pressed.
+Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
```js
const page = await browser.newPage();
@@ -4115,7 +3867,7 @@ await page.screenshot({ path: 'O.png' });
await browser.close();
```
-Shortcut for [keyboard.down(key)](#keyboarddownkey) and [keyboard.up(key)](#keyboardupkey).
+Shortcut for [`keyboard.down(key)`](#keyboarddownkey) and [`keyboard.up(key)`](#keyboardupkey).
#### keyboard.type(text[, options])
- `text` <[string]> A text to type into a focused element.
@@ -4125,7 +3877,7 @@ Shortcut for [keyboard.down(key)](#keyboarddownkey) and [keyboard.up(key)](#keyb
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
-To press a special key, like `Control` or `ArrowDown`, use [keyboard.press(key[, options])](#keyboardpresskey-options).
+To press a special key, like `Control` or `ArrowDown`, use [`keyboard.press(key[, options])`](#keyboardpresskey-options).
```js
await page.keyboard.type('Hello'); // Types instantly
@@ -4174,7 +3926,7 @@ await page.mouse.up();
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- returns: <[Promise]>
-Shortcut for [mouse.move(x, y[, options])](#mousemovex-y-options), [mouse.down([options])](#mousedownoptions), [mouse.up([options])](#mouseupoptions).
+Shortcut for [`mouse.move(x, y[, options])`](#mousemovex-y-options), [`mouse.down([options])`](#mousedownoptions), [`mouse.up([options])`](#mouseupoptions).
#### mouse.dblclick(x, y[, options])
- `x` <[number]>
@@ -4184,7 +3936,7 @@ Shortcut for [mouse.move(x, y[, options])](#mousemovex-y-options), [mouse.down([
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- returns: <[Promise]>
-Shortcut for [mouse.move(x, y[, options])](#mousemovex-y-options), [mouse.down([options])](#mousedownoptions), [mouse.up([options])](#mouseupoptions), [mouse.down([options])](#mousedownoptions) and [mouse.up([options])](#mouseupoptions).
+Shortcut for [`mouse.move(x, y[, options])`](#mousemovex-y-options), [`mouse.down([options])`](#mousedownoptions), [`mouse.up([options])`](#mouseupoptions), [`mouse.down([options])`](#mousedownoptions) and [`mouse.up([options])`](#mouseupoptions).
#### mouse.down([options])
- `options` <[Object]>
@@ -4213,8 +3965,7 @@ Dispatches a `mouseup` event.
### class: Touchscreen
-The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the
-touchscreen can only be used in browser contexts that have been intialized with `hasTouch` set to true.
+The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the touchscreen can only be used in browser contexts that have been intialized with `hasTouch` set to true.
#### touchscreen.tap(x, y)
- `x` <[number]>
@@ -4230,14 +3981,11 @@ Whenever the page sends a request for a network resource the following sequence
- [page.on('response')](#pageonresponse) emitted when/if the response status and headers are received for the request.
- [page.on('requestfinished')](#pageonrequestfinished) emitted when the response body is downloaded and the request is complete.
-If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event),
-the [page.on('requestfailed')](#pageonrequestfailed) event is emitted.
+If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event), the [page.on('requestfailed')](#pageonrequestfailed) event is emitted.
-> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
-will complete with `'requestfinished'` event.
+> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with `'requestfinished'` event.
-If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
-request is issued to a redirected url.
+If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new request is issued to a redirected url.
<!-- GEN:toc -->
- [request.failure()](#requestfailure)
@@ -4305,17 +4053,14 @@ Request's post body in a binary form, if any.
Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
-When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
-Otherwise it will be parsed as JSON.
+When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned. Otherwise it will be parsed as JSON.
#### request.redirectedFrom()
- returns: <[null]|[Request]>
Request that was redirected by the server to this one, if any.
-When the server responds with a redirect, Playwright creates a new [Request] object. The two requests are connected by
-`redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to
-construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
+When the server responds with a redirect, Playwright creates a new [Request] object. The two requests are connected by `redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
For example, if the website `http://example.com` redirects to `https://example.com`:
@@ -4336,7 +4081,7 @@ console.log(response.request().redirectedFrom()); // null
New request issued by the browser if the server responded with redirect.
-This method is the opposite of [request.redirectedFrom()](#requestredirectedfrom):
+This method is the opposite of [`request.redirectedFrom()`](#requestredirectedfrom):
```js
console.log(request.redirectedFrom().redirectedTo() === request); // true
@@ -4345,9 +4090,7 @@ console.log(request.redirectedFrom().redirectedTo() === request); // true
#### request.resourceType()
- returns: <[string]>
-Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the
-following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
-`websocket`, `manifest`, `other`.
+Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`, `websocket`, `manifest`, `other`.
#### request.response()
- returns: <[Promise]<[null]|[Response]>>
@@ -4366,9 +4109,7 @@ Returns the matching [Response] object, or `null` if the response was not receiv
- `responseStart` <[number]> Time immediately after the browser starts requesting the resource from the server, cache, or local resource. The value is given in milliseconds relative to `startTime`, -1 if not available.
- `responseEnd` <[number]> Time immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first. The value is given in milliseconds relative to `startTime`, -1 if not available.
-Returns resource timing information for given request. Most of the timing values become available upon the response,
-`responseEnd` becomes available when request finishes. Find more information at [Resource Timing
-API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
+Returns resource timing information for given request. Most of the timing values become available upon the response, `responseEnd` becomes available when request finishes. Find more information at [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
```js
const [request] = await Promise.all([
@@ -4460,8 +4201,7 @@ Contains the URL of the response.
### class: Selectors
-Selectors can be used to install custom selector engines. See [Working with selectors](#working-with-selectors) for more
-information.
+Selectors can be used to install custom selector engines. See [Working with selectors](#working-with-selectors) for more information.
<!-- GEN:toc -->
- [selectors.register(name, script[, options])](#selectorsregistername-script-options)
@@ -4521,8 +4261,7 @@ const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webk
### class: Route
-Whenever a network route is set up with [page.route(url, handler)](#pagerouteurl-handler) or [browserContext.route(url, handler)](#browsercontextrouteurl-handler), the `Route` object allows to
-handle the route.
+Whenever a network route is set up with [`page.route(url, handler)`](#pagerouteurl-handler) or [`browserContext.route(url, handler)`](#browsercontextrouteurl-handler), the `Route` object allows to handle the route.
<!-- GEN:toc -->
- [route.abort([errorCode])](#routeaborterrorcode)
@@ -4661,30 +4400,22 @@ Contains the URL of the WebSocket.
Returns the event data value.
-Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
-value. Will throw an error if the webSocket is closed before the event is fired.
+Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the webSocket is closed before the event is fired.
### class: TimeoutError
* extends: [Error]
-TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. [page.waitForSelector(selector[, options])](#pagewaitforselectorselector-options) or
-[browserType.launch([options])](#browsertypelaunchoptions).
+TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. [`page.waitForSelector(selector[, options])`](#pagewaitforselectorselector-options) or [`browserType.launch([options])`](#browsertypelaunchoptions).
### class: Accessibility
-The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by
-assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or
-[switches](https://en.wikipedia.org/wiki/Switch_access).
+The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or [switches](https://en.wikipedia.org/wiki/Switch_access).
-Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might
-have wildly different output.
+Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might have wildly different output.
-Blink - Chromium's rendering engine - has a concept of "accessibility tree", which is then translated into different
-platform-specific APIs. Accessibility namespace gives users access to the Blink Accessibility Tree.
+Blink - Chromium's rendering engine - has a concept of "accessibility tree", which is then translated into different platform-specific APIs. Accessibility namespace gives users access to the Blink Accessibility Tree.
-Most of the accessibility tree gets filtered out when converting from Blink AX Tree to Platform-specific AX-Tree or by
-assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing only the
-"interesting" nodes of the tree.
+Most of the accessibility tree gets filtered out when converting from Blink AX Tree to Platform-specific AX-Tree or by assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing only the "interesting" nodes of the tree.
<!-- GEN:toc -->
- [accessibility.snapshot([options])](#accessibilitysnapshotoptions)
@@ -4722,11 +4453,9 @@ assistive technologies themselves. By default, Playwright tries to approximate t
- `orientation` <[string]> Whether the node is oriented horizontally or vertically, if applicable.
- `children` <[Array]<[Object]>> Child [AXNode]s of this node, if any, if applicable.
-Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
-page.
+Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page.
-> **NOTE** The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
-Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
+> **NOTE** The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers. Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
An example of dumping the entire accessibility tree:
@@ -4755,9 +4484,7 @@ function findFocusedNode(node) {
### class: Worker
-The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
-event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
-worker is gone.
+The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker` event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the worker is gone.
```js
page.on('worker', worker => {
@@ -4789,12 +4516,9 @@ Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs
Returns the return value of `pageFunction`
-If the function passed to the `worker.evaluate` returns a [Promise], then `worker.evaluate` would wait for the promise
-to resolve and return its value.
+If the function passed to the `worker.evaluate` returns a [Promise], then `worker.evaluate` would wait for the promise to resolve and return its value.
-If the function passed to the `worker.evaluate` returns a non-[Serializable] value, then `worker.evaluate` returns
-`undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`:
-`-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
+If the function passed to the `worker.evaluate` returns a non-[Serializable] value, then `worker.evaluate` returns `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
#### worker.evaluateHandle(pageFunction[, arg])
- `pageFunction` <[function]|[string]> Function to be evaluated in the page context
@@ -4803,11 +4527,9 @@ If the function passed to the `worker.evaluate` returns a non-[Serializable] val
Returns the return value of `pageFunction` as in-page object (JSHandle).
-The only difference between `worker.evaluate` and `worker.evaluateHandle` is that `worker.evaluateHandle` returns
-in-page object (JSHandle).
+The only difference between `worker.evaluate` and `worker.evaluateHandle` is that `worker.evaluateHandle` returns in-page object (JSHandle).
-If the function passed to the `worker.evaluateHandle` returns a [Promise], then `worker.evaluateHandle` would wait for
-the promise to resolve and return its value.
+If the function passed to the `worker.evaluateHandle` returns a [Promise], then `worker.evaluateHandle` would wait for the promise to resolve and return its value.
#### worker.url()
- returns: <[string]>
@@ -4846,13 +4568,11 @@ Spawned browser application process.
Browser websocket url.
-Browser websocket endpoint which can be used as an argument to [browserType.connect(params)](#browsertypeconnectparams) to establish connection to the
-browser.
+Browser websocket endpoint which can be used as an argument to [`browserType.connect(params)`](#browsertypeconnectparams) to establish connection to the browser.
### class: BrowserType
-BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a
-typical example of using Playwright to drive automation:
+BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a typical example of using Playwright to drive automation:
```js
const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
@@ -4924,20 +4644,13 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
});
```
-> **Chromium-only** Playwright can also be used to control the Chrome browser, but it works best with the version of
-Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath` option with
-extreme caution.
+> **Chromium-only** Playwright can also be used to control the Chrome browser, but it works best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath` option with extreme caution.
>
-> If Google Chrome (rather than Chromium) is preferred, a [Chrome
-Canary](https://www.google.com/chrome/browser/canary.html) or [Dev
-Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested.
+> If Google Chrome (rather than Chromium) is preferred, a [Chrome Canary](https://www.google.com/chrome/browser/canary.html) or [Dev Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested.
>
-> In [browserType.launch([options])](#browsertypelaunchoptions) above, any mention of Chromium also applies to Chrome.
+> In [`browserType.launch([options])`](#browsertypelaunchoptions) above, any mention of Chromium also applies to Chrome.
>
-> See [`this article`](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for
-a description of the differences between Chromium and Chrome. [`This
-article`](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md) describes
-some differences for Linux users.
+> See [`this article`](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for a description of the differences between Chromium and Chrome. [`This article`](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md) describes some differences for Linux users.
#### browserType.launchPersistentContext(userDataDir[, options])
- `userDataDir` <[string]> Path to a User Data Directory, which stores browser session data like cookies and local storage. More details for [Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) and [Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile).
@@ -4977,22 +4690,22 @@ some differences for Linux users.
- `longitude` <[number]> Longitude between -180 and 180.
- `accuracy` <[number]> Non-negative accuracy value. Defaults to `0`.
- `locale` <[string]> Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules.
- - `permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [browserContext.grantPermissions(permissions[, options])](#browsercontextgrantpermissionspermissions-options) for more details.
+ - `permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [`browserContext.grantPermissions(permissions[, options])`](#browsercontextgrantpermissionspermissions-options) for more details.
- `extraHTTPHeaders` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
- `offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
- `httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
- `username` <[string]>
- `password` <[string]>
- - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(params)](#pageemulatemediaparams) for more details. Defaults to '`light`'.
+ - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [`page.emulateMedia(params)`](#pageemulatemediaparams) for more details. Defaults to '`light`'.
- `logger` <[Logger]> Logger sink for Playwright logging.
- - `videosPath` <[string]> **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to `videosPath` directory. If not specified, videos are not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for videos to be saved.
+ - `videosPath` <[string]> **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to `videosPath` directory. If not specified, videos are not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for videos to be saved.
- `videoSize` <[Object]> **NOTE** Use `recordVideo` instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.
- `width` <[number]> Video frame width.
- `height` <[number]> Video frame height.
- - `recordHar` <[Object]> Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for the HAR to be saved.
+ - `recordHar` <[Object]> Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for the HAR to be saved.
- `omitContent` <[boolean]> Optional setting to control whether to omit request content from the HAR. Defaults to `false`.
- `path` <[string]> Path on the filesystem to write the HAR file to.
- - `recordVideo` <[Object]> Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await [browserContext.close()](#browsercontextclose) for videos to be saved.
+ - `recordVideo` <[Object]> Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await [`browserContext.close()`](#browsercontextclose) for videos to be saved.
- `dir` <[string]> Path to the directory to put videos into.
- `size` <[Object]> Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of each page will be scaled down if necessary to fit the specified size.
- `width` <[number]> Video frame width.
@@ -5001,8 +4714,7 @@ some differences for Linux users.
Returns the persistent browser context instance.
-Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this
-context will automatically close the browser.
+Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this context will automatically close the browser.
#### browserType.launchServer([options])
- `options` <[Object]>
@@ -5030,8 +4742,7 @@ context will automatically close the browser.
Returns the browser app instance.
-Launches browser server that client can connect to. An example of launching a browser executable and connecting to it
-later:
+Launches browser server that client can connect to. An example of launching a browser executable and connecting to it later:
```js
const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'.
@@ -5092,9 +4803,7 @@ Determines whether sink is interested in the logger with the given name and seve
### class: ChromiumBrowser
* extends: [Browser]
-Chromium-specific features including Tracing, service worker support, etc. You can use
-[chromiumBrowser.startTracing([page, options])](#chromiumbrowserstarttracingpage-options) and [chromiumBrowser.stopTracing()](#chromiumbrowserstoptracing) to create a trace file which can be opened in
-Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/).
+Chromium-specific features including Tracing, service worker support, etc. You can use [`chromiumBrowser.startTracing([page, options])`](#chromiumbrowserstarttracingpage-options) and [`chromiumBrowser.stopTracing()`](#chromiumbrowserstoptracing) to create a trace file which can be opened in Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/).
```js
await browser.startTracing(page, {path: 'trace.json'});
@@ -5258,9 +4967,7 @@ Returns coverage is started
Returns coverage is started
-> **NOTE** Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created
-on the page using `eval` or `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous scripts will have
-`__playwright_evaluation_script__` as their URL.
+> **NOTE** Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created on the page using `eval` or `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous scripts will have `__playwright_evaluation_script__` as their URL.
#### chromiumCoverage.stopCSSCoverage()
- returns: <[Promise]<[Array]<[Object]>>>
@@ -5289,8 +4996,7 @@ Returns the array of coverage reports for all stylesheets
Returns the array of coverage reports for all scripts
-> **NOTE** JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are
-reported.
+> **NOTE** JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are reported.
### class: CDPSession
* extends: [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
@@ -5322,8 +5028,7 @@ await client.send('Animation.setPlaybackRate', {
#### cdpSession.detach()
- returns: <[Promise]>
-Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to
-send messages.
+Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to send messages.
#### cdpSession.send(method[, params])
- `method` <[string]> protocol method name
diff --git a/utils/doclint/cli.js b/utils/doclint/cli.js
index 953175368a..b0a29d5146 100755
--- a/utils/doclint/cli.js
+++ b/utils/doclint/cli.js
@@ -199,7 +199,7 @@ async function run() {
}
}
}
- api.setText([comment, header, renderMd(nodes), footer].join('\n'));
+ api.setText([comment, header, renderMd(nodes, 10000), footer].join('\n'));
// Generate links
preprocessor.generateLinks(api, signatures, messages);
diff --git a/utils/doclint/preprocessor/index.js b/utils/doclint/preprocessor/index.js
index 529e284ff0..737abee5c3 100644
--- a/utils/doclint/preprocessor/index.js
+++ b/utils/doclint/preprocessor/index.js
@@ -188,22 +188,32 @@ function generateLinks(source, signatures, messages) {
let match;
while (match = linkRegex.exec(line)) {
const [, name] = match;
+ const linkOffset = offset + lineNumber + match.index;
const hrefOffset = offset + lineNumber + match.index + 3 + name.length;
- const eventMatch = name.match(/.*on\('.*'\)/);
let replacement;
- if (eventMatch) {
- replacement = eventMatch[0];
- } else {
- const method = name.substring(0, name.length - 2);
+ const memberMatch = name.match(/`(event|method|namespace):\s(JS|CDP|[A-Z])([^.]+)\.(.*)`/m);
+ const paramMatch = name.match(/`(?:param|option):\s(.*)`/m);
+ if (!memberMatch && !paramMatch) {
+ messages.push(Message.error(`Bad link: ${source.filePath()}:${lineNumber + 1}: ${name}`));
+ return;
+ }
+ if (memberMatch && memberMatch[1] === 'event') {
+ replacement = `${memberMatch[2].toLowerCase() + memberMatch[3]}.on('${memberMatch[4]}')`;
+ sourceEdits.edit(linkOffset + 1, hrefOffset - 2, replacement);
+ } else if (memberMatch && memberMatch[1] === 'method') {
+ const method = memberMatch[2].toLowerCase() + memberMatch[3] + '.' + memberMatch[4];
let signature = signatures.get(method);
if (signature === undefined) {
messages.push(Message.error(`Bad method link: ${source.filePath()}:${lineNumber + 1}: ${method}`));
- signature = '\u2026';
+ signature = '(\u2026)';
}
- sourceEdits.edit(hrefOffset - 3, hrefOffset - 3, signature);
- replacement = name + signature;
+ replacement = method + '(' + signature + ')';
+ sourceEdits.edit(linkOffset + 2, hrefOffset - 3, replacement);
+ } else if (paramMatch) {
+ sourceEdits.edit(linkOffset, hrefOffset + 1, '`' + paramMatch[1] + '`');
}
- sourceEdits.edit(hrefOffset, hrefOffset, '#' + replacement.toLowerCase().replace(/[^a-z]/gm, ''));
+ if (replacement)
+ sourceEdits.edit(hrefOffset, hrefOffset, '#' + replacement.toLowerCase().replace(/[^a-z]/gm, ''));
}
offset += line.length;
});
diff --git a/utils/parse_md.js b/utils/parse_md.js
index e97feecc26..fde289b01d 100644
--- a/utils/parse_md.js
+++ b/utils/parse_md.js
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-const maxColumns = 120;
-
function normalizeLines(content) {
const inLines = content.split('\n');
let inCodeBlock = false;
@@ -133,23 +131,17 @@ function parseMd(content) {
return buildTree(normalizeLines(content));
}
-function renderMd(nodes) {
+function renderMd(nodes, maxColumns) {
const result = [];
let lastNode;
for (let node of nodes) {
- innerRenderMdNode(node, lastNode, result);
+ innerRenderMdNode(node, lastNode, result, maxColumns);
lastNode = node;
}
return result.join('\n');
}
-function renderMdNode(node, lastNode) {
- const result = [];
- innerRenderMdNode(node, lastNode, result);
- return result.join('\n');
-}
-
-function innerRenderMdNode(node, lastNode, result) {
+function innerRenderMdNode(node, lastNode, result, maxColumns = 120) {
const newLine = () => {
if (result[result.length - 1] !== '')
result.push('');
@@ -161,7 +153,7 @@ function innerRenderMdNode(node, lastNode, result) {
result.push(`${'#'.repeat(i)} ${node[`h${i}`]}`);
let lastNode = node;
for (const child of node.children) {
- innerRenderMdNode(child, lastNode, result);
+ innerRenderMdNode(child, lastNode, result, maxColumns);
lastNode = child;
}
break;
@@ -172,7 +164,7 @@ function innerRenderMdNode(node, lastNode, result) {
const bothComments = node.text.startsWith('>') && lastNode && lastNode.text && lastNode.text.startsWith('>');
if (!bothComments && lastNode && (lastNode.text || lastNode.li || lastNode.h1 || lastNode.h2 || lastNode.h3 || lastNode.h4))
newLine();
- printText(node, result);
+ printText(node, result, maxColumns);
}
if (node.code) {
@@ -207,7 +199,7 @@ function innerRenderMdNode(node, lastNode, result) {
}
}
-function printText(node, result) {
+function printText(node, result, maxColumns) {
let line = node.text;
while (line.length > maxColumns) {
let index = line.lastIndexOf(' ', maxColumns);