Skip to content

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

doc: generate class toc as a part of the api generation (#4852)

Pavel Feldmana5bd415edc33
diff --git a/docs-src/api-body.md b/docs-src/api-body.md
index 90a9ea1a5c..0087e2b98a 100644
--- a/docs-src/api-body.md
+++ b/docs-src/api-body.md
@@ -16,9 +16,6 @@ const { chromium, firefox, webkit } = require('playwright');
By default, the `playwright` NPM package automatically downloads browser executables during installation. The `playwright-core` NPM package can be used to skip automatic downloads.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## property: Playwright.chromium
- type: <[BrowserType]>
@@ -104,9 +101,6 @@ See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific
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 -->
-
## event: Browser.disconnected
Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
@@ -204,9 +198,6 @@ await page.goto('https://example.com');
await context.close();
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## event: BrowserContext.close
Emitted when Browser context gets closed. This might happen because of one of the following:
@@ -718,9 +709,6 @@ page.on('request', logRequest);
page.removeListener('request', logRequest);
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## event: Page.close
Emitted when the page closes.
@@ -2482,9 +2470,6 @@ const text = await frame.$eval('.selector', element => element.textContent);
console.log(text);
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Frame.$
- returns: <[null]|[ElementHandle]>
@@ -3337,12 +3322,6 @@ JSHandle.dispose`]. ElementHandles are auto-disposed when their origin frame get
ElementHandle instances can be used as an argument in [`method: Page.$eval`] and [`method: Page.evaluate`] methods.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
-<!-- GEN:toc-extends-JSHandle -->
-<!-- GEN:stop -->
-
## async method: ElementHandle.$
- returns: <[null]|[ElementHandle]>
@@ -3929,9 +3908,6 @@ destroyed.
JSHandle instances can be used as an argument in [`method: Page.$eval`], [`method: Page.evaluate`] and [`method:
Page.evaluateHandle`] methods.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## method: JSHandle.asElement
- returns: <[null]|[ElementHandle]>
@@ -4028,9 +4004,6 @@ error if the object has circular references.
[ConsoleMessage] objects are dispatched by page via the [`event: Page.console`] event.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## method: ConsoleMessage.args
- returns: <[Array]<[JSHandle]>>
@@ -4071,9 +4044,6 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Dialog.accept
Returns when the dialog has been accepted.
@@ -4125,9 +4095,6 @@ const path = await download.path();
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 -->
-<!-- GEN:stop -->
-
## async method: Download.createReadStream
- returns: <[null]|[Readable]>
@@ -4177,9 +4144,6 @@ When browser context is created with the `videosPath` option, each page has a vi
console.log(await page.video().path());
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Video.path
- returns: <[string]>
@@ -4196,9 +4160,6 @@ page.on('filechooser', async (fileChooser) => {
});
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## method: FileChooser.element
- returns: <[ElementHandle]>
@@ -4265,9 +4226,6 @@ await page.keyboard.press('Control+A');
await page.keyboard.press('Meta+A');
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Keyboard.down
Dispatches a `keydown` event.
@@ -4409,9 +4367,6 @@ await page.mouse.move(0, 0);
await page.mouse.up();
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Mouse.click
Shortcut for [`method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`].
@@ -4505,9 +4460,6 @@ 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.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## method: Request.failure
- returns: <[null]|[Object]>
- `errorText` <[string]> Human-readable error message, e.g. `'net::ERR_FAILED'`.
@@ -4639,9 +4591,6 @@ URL of the request.
[Response] class represents responses which are received by page.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Response.body
- returns: <[Buffer]>
@@ -4704,9 +4653,6 @@ Contains the URL of the response.
Selectors can be used to install custom selector engines. See [Working with selectors](#working-with-selectors) for more
information.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Selectors.register
An example of registering selector engine that queries elements based on a tag name:
@@ -4771,9 +4717,6 @@ guaranteed when this engine is used together with other registered engines.
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 -->
-
## async method: Route.abort
Aborts the route's request.
@@ -4863,9 +4806,6 @@ A request to be routed.
The [WebSocket] class represents websocket connections in the page.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## event: WebSocket.close
Fired when the websocket closes.
@@ -4939,9 +4879,6 @@ Most of the accessibility tree gets filtered out when converting from Blink AX T
assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing only the
"interesting" nodes of the tree.
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: Accessibility.snapshot
- returns: <[null]|[Object]>
- `role` <[string]> The [role](https://www.w3.org/TR/wai-aria/#usage_intro).
@@ -5030,9 +4967,6 @@ for (const worker of page.workers())
console.log(' ' + worker.url());
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## event: Worker.close
- type: <[Worker]>
@@ -5086,9 +5020,6 @@ Optional argument to pass to [`param: pageFunction`]
# class: BrowserServer
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## event: BrowserServer.close
Emitted when the browser server closes.
@@ -5131,9 +5062,6 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: BrowserType.connect
- returns: <[Browser]>
@@ -5515,9 +5443,6 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## method: Logger.isEnabled
- returns: <[boolean]>
@@ -5570,12 +5495,6 @@ await page.goto('https://www.google.com');
await browser.stopTracing();
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
-<!-- GEN:toc-extends-Browser -->
-<!-- GEN:stop -->
-
## async method: ChromiumBrowser.newBrowserCDPSession
- returns: <[CDPSession]>
@@ -5619,12 +5538,6 @@ Chromium-specific features including background pages, service worker support, e
const backgroundPage = await context.waitForEvent('backgroundpage');
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
-<!-- GEN:toc-extends-BrowserContext -->
-<!-- GEN:stop -->
-
## event: ChromiumBrowserContext.backgroundpage
- type: <[Page]>
@@ -5683,9 +5596,6 @@ const v8toIstanbul = require('v8-to-istanbul');
})();
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: ChromiumCoverage.startCSSCoverage
Returns coverage is started
@@ -5765,9 +5675,6 @@ await client.send('Animation.setPlaybackRate', {
});
```
-<!-- GEN:toc -->
-<!-- GEN:stop -->
-
## async method: CDPSession.detach
Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to
@@ -5791,13 +5698,7 @@ Optional method parameters
Firefox browser instance does not expose Firefox-specific features.
-<!-- GEN:toc-extends-Browser -->
-<!-- GEN:stop -->
-
# class: WebKitBrowser
* extends: [Browser]
WebKit browser instance does not expose WebKit-specific features.
-
-<!-- GEN:toc-extends-Browser -->
-<!-- GEN:stop -->
diff --git a/docs/api.md b/docs/api.md
index fc627e86d5..c5e094ac61 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -62,14 +62,13 @@ const { chromium, firefox, webkit } = require('playwright');
By default, the `playwright` NPM package automatically downloads browser executables during installation. The `playwright-core` NPM package can be used to skip automatic downloads.
-<!-- GEN:toc -->
+<!-- TOC -->
- [playwright.chromium](#playwrightchromium)
- [playwright.devices](#playwrightdevices)
- [playwright.errors](#playwrighterrors)
- [playwright.firefox](#playwrightfirefox)
- [playwright.selectors](#playwrightselectors)
- [playwright.webkit](#playwrightwebkit)
-<!-- GEN:stop -->
#### playwright.chromium
- type: <[BrowserType]>
@@ -79,7 +78,7 @@ This object can be used to launch or connect to Chromium, returning instances of
#### playwright.devices
- type: <[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 [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).
```js
const { webkit, devices } = require('playwright');
@@ -101,7 +100,7 @@ const iPhone = devices['iPhone 6'];
- type: <[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) might fail if the selector doesn't match any nodes during the given timeframe.
+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. These classes are available via [`playwright.errors`](#playwrighterrors).
@@ -137,7 +136,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]:
@@ -152,9 +151,9 @@ 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 -->
+<!-- TOC -->
- [browser.on('disconnected')](#browserondisconnected)
- [browser.close()](#browserclose)
- [browser.contexts()](#browsercontexts)
@@ -162,20 +161,19 @@ See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific
- [browser.newContext([options])](#browsernewcontextoptions)
- [browser.newPage([options])](#browsernewpageoptions)
- [browser.version()](#browserversion)
-<!-- GEN:stop -->
#### browser.on('disconnected')
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.
@@ -201,7 +199,7 @@ Indicates that the browser is connected.
- `options` <[Object]>
- `acceptDownloads` <[boolean]> Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
- `bypassCSP` <[boolean]> Toggles bypassing page's Content-Security-Policy.
- - `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`'.
- `deviceScaleFactor` <[number]> Specify device scale factor (can be thought of as dpr). Defaults to `1`.
- `extraHTTPHeaders` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
- `geolocation` <[Object]>
@@ -218,21 +216,21 @@ Indicates that the browser is connected.
- `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.
- `logger` <[Logger]> Logger sink for Playwright logging.
- `offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
- - `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.
- `proxy` <[Object]> Network proxy settings to use with this context. Note that browser needs to be launched with the global proxy for this option to work. If all contexts override the proxy, global proxy will be never used and can be any string, for example `launch({ proxy: { server: 'per-context' } })`.
- `server` <[string]> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example `http://myproxy.com:3128` or `socks5://myproxy.com:3128`. Short form `myproxy.com:3128` is considered an HTTP proxy.
- `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.
- - `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.
- `height` <[number]> Video frame height.
- - `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**
@@ -253,7 +251,7 @@ Indicates that the browser is connected.
- `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.
- - `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.
- `viewport` <[null]|[Object]> Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `null` disables the default viewport.
- `width` <[number]> page width in pixels.
- `height` <[number]> page height in pixels.
@@ -276,7 +274,7 @@ Creates a new browser context. It won't share cookies/cache with other browser c
- `options` <[Object]>
- `acceptDownloads` <[boolean]> Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
- `bypassCSP` <[boolean]> Toggles bypassing page's Content-Security-Policy.
- - `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`'.
- `deviceScaleFactor` <[number]> Specify device scale factor (can be thought of as dpr). Defaults to `1`.
- `extraHTTPHeaders` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
- `geolocation` <[Object]>
@@ -293,21 +291,21 @@ Creates a new browser context. It won't share cookies/cache with other browser c
- `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.
- `logger` <[Logger]> Logger sink for Playwright logging.
- `offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
- - `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.
- `proxy` <[Object]> Network proxy settings to use with this context. Note that browser needs to be launched with the global proxy for this option to work. If all contexts override the proxy, global proxy will be never used and can be any string, for example `launch({ proxy: { server: 'per-context' } })`.
- `server` <[string]> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example `http://myproxy.com:3128` or `socks5://myproxy.com:3128`. Short form `myproxy.com:3128` is considered an HTTP proxy.
- `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.
- - `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.
- `height` <[number]> Video frame height.
- - `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**
@@ -328,7 +326,7 @@ Creates a new browser context. It won't share cookies/cache with other browser c
- `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.
- - `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.
- `viewport` <[null]|[Object]> Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `null` disables the default viewport.
- `width` <[number]> page width in pixels.
- `height` <[number]> page height in pixels.
@@ -336,7 +334,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]>
@@ -364,7 +362,7 @@ await page.goto('https://example.com');
await context.close();
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [browserContext.on('close')](#browsercontextonclose)
- [browserContext.on('page')](#browsercontextonpage)
- [browserContext.addCookies(cookies)](#browsercontextaddcookiescookies)
@@ -389,19 +387,18 @@ await context.close();
- [browserContext.storageState([options])](#browsercontextstoragestateoptions)
- [browserContext.unroute(url[, handler])](#browsercontextunrouteurl-handler)
- [browserContext.waitForEvent(event[, optionsOrPredicate])](#browsercontextwaitforeventevent-optionsorpredicate)
-<!-- GEN:stop -->
#### browserContext.on('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')
- type: <[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.
@@ -413,7 +410,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]>>
@@ -428,7 +425,7 @@ console.log(await page.evaluate('location.href'));
- `sameSite` <"Strict"|"Lax"|"None"> Optional.
- 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]);
@@ -461,7 +458,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]>
@@ -517,7 +514,7 @@ The method adds a function called `name` on the `window` object of every frame i
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:
@@ -566,7 +563,7 @@ The method adds a function called `name` on the `window` object of every frame i
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:
@@ -624,7 +621,7 @@ 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.
@@ -653,7 +650,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.
@@ -661,27 +658,27 @@ Page routes (set up with [`page.route(url, handler)`](#pagerouteurl-handler)) ta
- `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.
@@ -698,7 +695,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]>
@@ -736,17 +733,17 @@ Provide credentials for [HTTP authentication](https://developer.mozilla.org/en-U
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)`.
- `optionsOrPredicate` <[Function]|[Object]> Either a predicate that receives an event or an options object. Optional.
- `predicate` <[Function]> receives the event data and resolves to truthy value when the waiting should resolve.
- - `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]<[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.
@@ -797,7 +794,7 @@ page.on('request', logRequest);
page.removeListener('request', logRequest);
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [page.on('close')](#pageonclose)
- [page.on('console')](#pageonconsole)
- [page.on('crash')](#pageoncrash)
@@ -886,7 +883,6 @@ page.removeListener('request', logRequest);
- [page.waitForSelector(selector[, options])](#pagewaitforselectorselector-options)
- [page.waitForTimeout(timeout)](#pagewaitfortimeouttimeout)
- [page.workers()](#pageworkers)
-<!-- GEN:stop -->
#### page.on('close')
@@ -941,7 +937,7 @@ await new Promise((resolve, reject) => {
#### page.on('dialog')
- type: <[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')
@@ -957,7 +953,7 @@ Emitted when attachment download started. User can access basic file operations
#### page.on('filechooser')
- type: <[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) => {
@@ -992,7 +988,7 @@ Emitted when an uncaught exception happens within the page.
#### page.on('popup')
- type: <[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.
+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.
@@ -1004,19 +1000,19 @@ 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')
- type: <[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')
- type: <[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')
- type: <[Request]>
@@ -1044,7 +1040,7 @@ Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/We
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.
@@ -1052,7 +1048,7 @@ Shortcut for main frame's [`frame.$(selector)`](#frameselector).
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-1).
#### page.$eval(selector, pageFunction[, arg])
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -1062,7 +1058,7 @@ Shortcut for main frame's [`frame.$$(selector)`](#frameselector).
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(selector, pageFunction[, arg])`](#pageevalselector-pagefunction-arg) 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:
@@ -1072,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.
@@ -1082,7 +1078,7 @@ Shortcut for main frame's [`frame.$eval(selector, pageFunction[, arg])`](#framee
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(selector, pageFunction[, arg])`](#pageevalselector-pagefunction-arg) 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-1) would wait for the promise to resolve and return its value.
Examples:
@@ -1117,7 +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]>
@@ -1129,7 +1125,7 @@ await page.addInitScript(preloadFile);
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]>
@@ -1140,7 +1136,7 @@ Shortcut for main frame's [`frame.addScriptTag(params)`](#frameaddscripttagparam
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]>
@@ -1152,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:
@@ -1160,13 +1156,13 @@ This method checks an element matching `selector` by performing the following st
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. Scroll the element into view if needed.
-1. Use [`page.mouse`](#pagemouse) to click in the center of the element.
+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. 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.
-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.
@@ -1180,19 +1176,19 @@ Shortcut for main frame's [`frame.check(selector[, options])`](#framecheckselect
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
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. 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.
-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]>
@@ -1204,7 +1200,7 @@ If `runBeforeUnload` is `false`, does not run any unload handlers and waits for
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')`](#pageondialog) event.
+> and should be handled manually via [page.on('dialog')](#pageondialog) event.
#### page.content()
- returns: <[Promise]<[string]>>
@@ -1232,28 +1228,28 @@ Browser-specific Coverage implementation, only available for Chromium atm. See [
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
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. 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.
> **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).
@@ -1352,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
@@ -1391,7 +1387,7 @@ The method adds a function called `name` on the `window` object of every frame i
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.
@@ -1442,7 +1438,7 @@ The method adds a function called `name` on the `window` object of every frame i
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.
@@ -1503,24 +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.
-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.
-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.
@@ -1547,14 +1543,14 @@ 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.
@@ -1567,7 +1563,7 @@ 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.
@@ -1581,8 +1577,8 @@ 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]>
- - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [`page.setExtraHTTPHeaders(headers)`](#pagesetextrahttpheadersheaders).
- - `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.
+ - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [page.setExtraHTTPHeaders(headers)](#pagesetextrahttpheadersheaders).
+ - `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.
@@ -1598,12 +1594,12 @@ Returns the main resource response. In case of multiple redirects, the navigatio
* 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).
-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.
@@ -1613,24 +1609,24 @@ Shortcut for main frame's [`frame.goto(url[, options])`](#framegotourl-options)
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
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 `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.
-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`.
@@ -1638,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`.
@@ -1694,7 +1690,7 @@ 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.
@@ -1740,10 +1736,10 @@ 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:
@@ -1771,7 +1767,7 @@ 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.
@@ -1809,7 +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.
@@ -1824,7 +1820,7 @@ Page routes take precedence over browser context routes (set up with [`browserCo
- `omitBackground` <[boolean]> Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images. Defaults to `false`.
- `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.
- `quality` <[number]> The quality of the image, between 0-100. Not applicable to `png` images.
- - `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.
- `type` <"png"|"jpeg"> Specify screenshot type, defaults to `png`.
- returns: <[Promise]<[Buffer]>>
@@ -1840,7 +1836,7 @@ Returns the buffer with the captured screenshot.
- `index` <[number]> Matches by the index. Optional.
- `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.
@@ -1859,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.
@@ -1875,21 +1871,21 @@ Shortcut for main frame's [`frame.selectOption(selector, values[, options])`](#f
- `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.
@@ -1907,7 +1903,7 @@ 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).
@@ -1920,7 +1916,7 @@ Sets the value of the file input to these file paths or files. If some of the `f
- `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.
@@ -1942,26 +1938,26 @@ await page.goto('https://example.com');
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
1. Scroll the element into view if needed.
-1. Use [`page.touchscreen`](#pagetouchscreen) to tap the center of the element, or the specified `position`.
+1. Use [page.touchscreen](#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.
> **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`.
@@ -1969,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
- type: <[Touchscreen]>
@@ -1980,26 +1976,26 @@ Returns the page's title. Shortcut for main frame's [`frame.title()`](#frametitl
- `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:
@@ -2007,25 +2003,25 @@ This method unchecks an element matching `selector` by performing the following
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. Scroll the element into view if needed.
-1. Use [`page.mouse`](#pagemouse) to click in the center of the element.
+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. 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.
-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]>
@@ -2041,7 +2037,7 @@ Video object associated with this page.
- `event` <[string]> Event name, same one would pass into `page.on(event)`.
- `optionsOrPredicate` <[Function]|[Object]> Either a predicate that receives an event or an options object. Optional.
- `predicate` <[Function]> receives the event data and resolves to truthy value when the waiting should resolve.
- - `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]<[Object]>>
Returns the event data value.
@@ -2053,7 +2049,7 @@ Waits for event to fire and passes its value into the predicate function. Return
- `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.
@@ -2080,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"> Optional load state to wait for, defaults to `load`. If the state has been already reached while loading current document, the method resolves immediately. Can be one of:
@@ -2088,7 +2084,7 @@ 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.
@@ -2109,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.
@@ -2134,12 +2130,12 @@ 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([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.
@@ -2157,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.
@@ -2176,7 +2172,7 @@ 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`.
@@ -2215,7 +2211,7 @@ Note that `page.waitForTimeout()` should only be used for debugging. Tests using
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]>>
@@ -2228,12 +2224,12 @@ This method returns all of the dedicated [WebWorkers](https://developer.mozilla.
### 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.
-* [`page.on('framenavigated')`](#pageonframenavigated) - fired when the frame commits navigation to a different URL.
-* [`page.on('framedetached')`](#pageonframedetached) - fired when the frame gets detached from the page. A Frame can be detached from the page only once.
+* [page.on('frameattached')](#pageonframeattached) - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
+* [page.on('framenavigated')](#pageonframenavigated) - fired when the frame commits navigation to a different URL.
+* [page.on('framedetached')](#pageonframedetached) - 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:
@@ -2264,7 +2260,7 @@ const text = await frame.$eval('.selector', element => element.textContent);
console.log(text);
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [frame.$(selector)](#frameselector)
- [frame.$$(selector)](#frameselector-1)
- [frame.$eval(selector, pageFunction[, arg])](#frameevalselector-pagefunction-arg)
@@ -2306,7 +2302,6 @@ console.log(text);
- [frame.waitForNavigation([options])](#framewaitfornavigationoptions)
- [frame.waitForSelector(selector[, options])](#framewaitforselectorselector-options)
- [frame.waitForTimeout(timeout)](#framewaitfortimeouttimeout)
-<!-- GEN:stop -->
#### frame.$(selector)
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -2390,7 +2385,7 @@ Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<s
- `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:
@@ -2398,7 +2393,7 @@ This method checks an element matching `selector` by performing the following st
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. Scroll the element into view if needed.
-1. Use [`page.mouse`](#pagemouse) to click in the center of the element.
+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. Ensure that the element is now checked. If not, this method rejects.
@@ -2419,14 +2414,14 @@ When all steps combined have not finished during the specified `timeout`, this m
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
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. 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.
@@ -2447,14 +2442,14 @@ Gets the full HTML contents of the frame, including the doctype.
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
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. 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.
@@ -2466,7 +2461,7 @@ When all steps combined have not finished during the specified `timeout`, this m
- `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).
@@ -2562,17 +2557,17 @@ 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.
-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.
@@ -2582,7 +2577,7 @@ This method fetches an element with `selector` and focuses it. If there's no ele
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.
@@ -2596,7 +2591,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.
@@ -2604,8 +2599,8 @@ 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]>
- - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [`page.setExtraHTTPHeaders(headers)`](#pagesetextrahttpheadersheaders).
- - `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.
+ - `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [page.setExtraHTTPHeaders(headers)](#pagesetextrahttpheadersheaders).
+ - `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.
@@ -2621,7 +2616,7 @@ Returns the main resource response. In case of multiple redirects, the navigatio
* 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).
@@ -2634,14 +2629,14 @@ Returns the main resource response. In case of multiple redirects, the navigatio
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
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 `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.
@@ -2649,7 +2644,7 @@ When all steps combined have not finished during the specified `timeout`, this m
#### 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`.
@@ -2657,7 +2652,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`.
@@ -2692,7 +2687,7 @@ 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:
@@ -2715,7 +2710,7 @@ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported a
- `index` <[number]> Matches by the index. Optional.
- `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.
@@ -2736,7 +2731,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.
@@ -2751,7 +2746,7 @@ 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).
@@ -2767,14 +2762,14 @@ Sets the value of the file input to these file paths or files. If some of the `f
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
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.
1. Scroll the element into view if needed.
-1. Use [`page.touchscreen`](#pagetouchscreen) to tap the center of the element, or the specified `position`.
+1. Use [page.touchscreen](#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.
@@ -2784,7 +2779,7 @@ When all steps combined have not finished during the specified `timeout`, this m
#### 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`.
@@ -2800,12 +2795,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
@@ -2817,7 +2812,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:
@@ -2825,7 +2820,7 @@ This method checks an element matching `selector` by performing the following st
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. Scroll the element into view if needed.
-1. Use [`page.mouse`](#pagemouse) to click in the center of the element.
+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. Ensure that the element is now unchecked. If not, this method rejects.
@@ -2841,7 +2836,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.
@@ -2874,7 +2869,7 @@ 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.
@@ -2888,7 +2883,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.
@@ -2917,7 +2912,7 @@ const [response] = await Promise.all([
* `'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`.
@@ -2956,7 +2951,7 @@ Note that `frame.waitForTimeout()` should only be used for debugging. Tests usin
### 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'.
@@ -2971,11 +2966,11 @@ 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 -->
+<!-- TOC -->
- [elementHandle.$(selector)](#elementhandleselector)
- [elementHandle.$$(selector)](#elementhandleselector-1)
- [elementHandle.$eval(selector, pageFunction[, arg])](#elementhandleevalselector-pagefunction-arg)
@@ -3005,9 +3000,6 @@ ElementHandle instances can be used as an argument in [`page.$eval(selector, pag
- [elementHandle.uncheck([options])](#elementhandleuncheckoptions)
- [elementHandle.waitForElementState(state[, options])](#elementhandlewaitforelementstatestate-options)
- [elementHandle.waitForSelector(selector[, options])](#elementhandlewaitforselectorselector-options)
-<!-- GEN:stop -->
-
-<!-- GEN:toc-extends-JSHandle -->
- [jsHandle.asElement()](#jshandleaselement)
- [jsHandle.dispose()](#jshandledispose)
- [jsHandle.evaluate(pageFunction[, arg])](#jshandleevaluatepagefunction-arg)
@@ -3015,7 +3007,6 @@ ElementHandle instances can be used as an argument in [`page.$eval(selector, pag
- [jsHandle.getProperties()](#jshandlegetproperties)
- [jsHandle.getProperty(propertyName)](#jshandlegetpropertypropertyname)
- [jsHandle.jsonValue()](#jshandlejsonvalue)
-<!-- GEN:stop -->
#### elementHandle.$(selector)
- `selector` <[string]> A selector to query for. See [working with selectors](#working-with-selectors) for more details.
@@ -3099,14 +3090,14 @@ 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:
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. Scroll the element into view if needed.
-1. Use [`page.mouse`](#pagemouse) to click in the center of the element.
+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. Ensure that the element is now checked. If not, this method rejects.
@@ -3125,13 +3116,13 @@ When all steps combined have not finished during the specified `timeout`, this m
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
1. Wait for [actionability](./actionability.md) checks on the element, unless `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. 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.
If the element is detached from the DOM at any moment during the action, this method rejects.
@@ -3153,13 +3144,13 @@ Returns the content frame for element handles referencing iframe nodes, or `null
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
1. Wait for [actionability](./actionability.md) checks on the element, unless `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. 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.
If the element is detached from the DOM at any moment during the action, this method rejects.
@@ -3202,7 +3193,7 @@ 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.
@@ -3225,13 +3216,13 @@ Returns element attribute value.
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
1. Wait for [actionability](./actionability.md) checks on the element, unless `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 `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.
@@ -3258,10 +3249,10 @@ 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:
@@ -3280,7 +3271,7 @@ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported a
- `omitBackground` <[boolean]> Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images. Defaults to `false`.
- `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.
- `quality` <[number]> The quality of the image, between 0-100. Not applicable to `png` images.
- - `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.
- `type` <"png"|"jpeg"> Specify screenshot type, defaults to `png`.
- returns: <[Promise]<[Buffer]>>
@@ -3290,7 +3281,7 @@ This method waits for the [actionability](./actionability.md) checks, then scrol
#### 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```.
@@ -3304,7 +3295,7 @@ Throws when `elementHandle` does not point to an element [connected](https://dev
- `index` <[number]> Matches by the index. Optional.
- `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.
@@ -3327,7 +3318,7 @@ 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.
@@ -3339,7 +3330,7 @@ This method waits for [actionability](./actionability.md) checks, then focuses t
- `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).
@@ -3354,13 +3345,13 @@ Sets the value of the file input to these file paths or files. If some of the `f
- `position` <[Object]> A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `x` <[number]>
- `y` <[number]>
- - `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:
1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
1. Scroll the element into view if needed.
-1. Use [`page.touchscreen`](#pagetouchscreen) to tap the center of the element, or the specified `position`.
+1. Use [page.touchscreen](#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.
If the element is detached from the DOM at any moment during the action, this method rejects.
@@ -3379,12 +3370,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
@@ -3403,14 +3394,14 @@ 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:
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. Scroll the element into view if needed.
-1. Use [`page.mouse`](#pagemouse) to click in the center of the element.
+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. Ensure that the element is now unchecked. If not, this method rejects.
@@ -3421,7 +3412,7 @@ When all steps combined have not finished during the specified `timeout`, this m
#### 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`.
@@ -3443,7 +3434,7 @@ 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`.
@@ -3457,24 +3448,24 @@ 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.
[ElementHandle]: #class-elementhandle "ElementHandle"
### 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 -->
+<!-- TOC -->
- [jsHandle.asElement()](#jshandleaselement)
- [jsHandle.dispose()](#jshandledispose)
- [jsHandle.evaluate(pageFunction[, arg])](#jshandleevaluatepagefunction-arg)
@@ -3482,7 +3473,6 @@ JSHandle instances can be used as an argument in [`page.$eval(selector, pageFunc
- [jsHandle.getProperties()](#jshandlegetproperties)
- [jsHandle.getProperty(propertyName)](#jshandlegetpropertypropertyname)
- [jsHandle.jsonValue()](#jshandlejsonvalue)
-<!-- GEN:stop -->
#### jsHandle.asElement()
- returns: <[null]|[ElementHandle]>
@@ -3525,7 +3515,7 @@ The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is
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]>>>
@@ -3557,14 +3547,13 @@ Returns a JSON representation of the object. If the object has a `toJSON` functi
### class: ConsoleMessage
-[ConsoleMessage] objects are dispatched by page via the [`page.on('console')`](#pageonconsole) event.
+[ConsoleMessage] objects are dispatched by page via the [page.on('console')](#pageonconsole) event.
-<!-- GEN:toc -->
+<!-- TOC -->
- [consoleMessage.args()](#consolemessageargs)
- [consoleMessage.location()](#consolemessagelocation)
- [consoleMessage.text()](#consolemessagetext)
- [consoleMessage.type()](#consolemessagetype)
-<!-- GEN:stop -->
#### consoleMessage.args()
- returns: <[Array]<[JSHandle]>>
@@ -3587,7 +3576,7 @@ One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'
### class: Dialog
-[Dialog] objects are dispatched by page via the [`page.on('dialog')`](#pageondialog) event.
+[Dialog] objects are dispatched by page via the [page.on('dialog')](#pageondialog) event.
An example of using `Dialog` class:
@@ -3606,13 +3595,12 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [dialog.accept([promptText])](#dialogacceptprompttext)
- [dialog.defaultValue()](#dialogdefaultvalue)
- [dialog.dismiss()](#dialogdismiss)
- [dialog.message()](#dialogmessage)
- [dialog.type()](#dialogtype)
-<!-- GEN:stop -->
#### dialog.accept([promptText])
- `promptText` <[string]> A text to enter in prompt. Does not cause any effects if the dialog's `type` is not prompt. Optional.
@@ -3644,7 +3632,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')`](#pageondownload) event.
+[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.
@@ -3662,7 +3650,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.
-<!-- GEN:toc -->
+<!-- TOC -->
- [download.createReadStream()](#downloadcreatereadstream)
- [download.delete()](#downloaddelete)
- [download.failure()](#downloadfailure)
@@ -3670,7 +3658,6 @@ const path = await download.path();
- [download.saveAs(path)](#downloadsaveaspath)
- [download.suggestedFilename()](#downloadsuggestedfilename)
- [download.url()](#downloadurl)
-<!-- GEN:stop -->
#### download.createReadStream()
- returns: <[Promise]<[null]|[Readable]>>
@@ -3718,9 +3705,8 @@ When browser context is created with the `videosPath` option, each page has a vi
console.log(await page.video().path());
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [video.path()](#videopath)
-<!-- GEN:stop -->
#### video.path()
- returns: <[Promise]<[string]>>
@@ -3731,7 +3717,7 @@ Returns the file system path this video will be recorded to. The video is guaran
### class: FileChooser
-[FileChooser] objects are dispatched by the page in the [`page.on('filechooser')`](#pageonfilechooser) event.
+[FileChooser] objects are dispatched by the page in the [page.on('filechooser')](#pageonfilechooser) event.
```js
page.on('filechooser', async (fileChooser) => {
@@ -3739,12 +3725,11 @@ page.on('filechooser', async (fileChooser) => {
});
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [fileChooser.element()](#filechooserelement)
- [fileChooser.isMultiple()](#filechooserismultiple)
- [fileChooser.page()](#filechooserpage)
- [fileChooser.setFiles(files[, options])](#filechoosersetfilesfiles-options)
-<!-- GEN:stop -->
#### fileChooser.element()
- returns: <[ElementHandle]>
@@ -3768,7 +3753,7 @@ 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.
@@ -3777,9 +3762,9 @@ Sets the value of the file input this chooser is associated with. If some of the
### 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:
@@ -3813,13 +3798,12 @@ await page.keyboard.press('Control+A');
await page.keyboard.press('Meta+A');
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [keyboard.down(key)](#keyboarddownkey)
- [keyboard.insertText(text)](#keyboardinserttexttext)
- [keyboard.press(key[, options])](#keyboardpresskey-options)
- [keyboard.type(text[, options])](#keyboardtypetext-options)
- [keyboard.up(key)](#keyboardupkey)
-<!-- GEN:stop -->
#### keyboard.down(key)
- `key` <[string]> Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
@@ -3837,9 +3821,9 @@ Holding down `Shift` will type the text that corresponds to the `key` in the upp
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.
@@ -3885,7 +3869,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.
@@ -3895,7 +3879,7 @@ Shortcut for [`keyboard.down(key)`](#keyboarddownkey) and [`keyboard.up(key)`](#
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
@@ -3916,7 +3900,7 @@ Dispatches a `keyup` event.
The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
-Every `page` object has its own Mouse, accessible with [`page.mouse`](#pagemouse).
+Every `page` object has its own Mouse, accessible with [page.mouse](#pagemouse).
```js
// Using ‘page.mouse’ to trace a 100x100 square.
@@ -3929,13 +3913,12 @@ await page.mouse.move(0, 0);
await page.mouse.up();
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [mouse.click(x, y[, options])](#mouseclickx-y-options)
- [mouse.dblclick(x, y[, options])](#mousedblclickx-y-options)
- [mouse.down([options])](#mousedownoptions)
- [mouse.move(x, y[, options])](#mousemovex-y-options)
- [mouse.up([options])](#mouseupoptions)
-<!-- GEN:stop -->
#### mouse.click(x, y[, options])
- `x` <[number]>
@@ -3946,7 +3929,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]>
@@ -3956,7 +3939,7 @@ Shortcut for [`mouse.move(x, y[, options])`](#mousemovex-y-options), [`mouse.dow
- `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]>
@@ -3989,6 +3972,9 @@ Dispatches a `mouseup` event.
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.
+<!-- TOC -->
+- [touchscreen.tap(x, y)](#touchscreentapx-y)
+
#### touchscreen.tap(x, y)
- `x` <[number]>
- `y` <[number]>
@@ -4001,17 +3987,17 @@ 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')`](#pageonrequest) emitted when the request is issued by the page.
-* [`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.
+* [page.on('request')](#pageonrequest) emitted when the request is issued by the page.
+* [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.
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 -->
+<!-- TOC -->
- [request.failure()](#requestfailure)
- [request.frame()](#requestframe)
- [request.headers()](#requestheaders)
@@ -4026,7 +4012,6 @@ If request gets a 'redirect' response, the request is successfully finished with
- [request.response()](#requestresponse)
- [request.timing()](#requesttiming)
- [request.url()](#requesturl)
-<!-- GEN:stop -->
#### request.failure()
- returns: <[null]|[Object]>
@@ -4105,7 +4090,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
@@ -4154,7 +4139,7 @@ URL of the request.
[Response] class represents responses which are received by page.
-<!-- GEN:toc -->
+<!-- TOC -->
- [response.body()](#responsebody)
- [response.finished()](#responsefinished)
- [response.frame()](#responseframe)
@@ -4166,7 +4151,6 @@ URL of the request.
- [response.statusText()](#responsestatustext)
- [response.text()](#responsetext)
- [response.url()](#responseurl)
-<!-- GEN:stop -->
#### response.body()
- returns: <[Promise]<[Buffer]>>
@@ -4231,9 +4215,8 @@ Contains the URL of the response.
Selectors can be used to install custom selector engines. See [Working with selectors](#working-with-selectors) for more information.
-<!-- GEN:toc -->
+<!-- TOC -->
- [selectors.register(name, script[, options])](#selectorsregistername-script-options)
-<!-- GEN:stop -->
#### selectors.register(name, script[, options])
- `name` <[string]> Name that is used in selectors as a prefix, e.g. `{name: 'foo'}` enables `foo=myselectorbody` selectors. May only contain `[a-zA-Z0-9_]` characters.
@@ -4285,14 +4268,13 @@ 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 -->
+<!-- TOC -->
- [route.abort([errorCode])](#routeaborterrorcode)
- [route.continue([overrides])](#routecontinueoverrides)
- [route.fulfill(response)](#routefulfillresponse)
- [route.request()](#routerequest)
-<!-- GEN:stop -->
#### route.abort([errorCode])
- `errorCode` <[string]> Optional error code. Defaults to `failed`, could be one of the following:
@@ -4376,7 +4358,7 @@ A request to be routed.
The [WebSocket] class represents websocket connections in the page.
-<!-- GEN:toc -->
+<!-- TOC -->
- [webSocket.on('close')](#websocketonclose)
- [webSocket.on('framereceived')](#websocketonframereceived)
- [webSocket.on('framesent')](#websocketonframesent)
@@ -4384,7 +4366,6 @@ The [WebSocket] class represents websocket connections in the page.
- [webSocket.isClosed()](#websocketisclosed)
- [webSocket.url()](#websocketurl)
- [webSocket.waitForEvent(event[, optionsOrPredicate])](#websocketwaitforeventevent-optionsorpredicate)
-<!-- GEN:stop -->
#### webSocket.on('close')
@@ -4421,7 +4402,7 @@ Contains the URL of the WebSocket.
- `event` <[string]> Event name, same one would pass into `webSocket.on(event)`.
- `optionsOrPredicate` <[Function]|[Object]> Either a predicate that receives an event or an options object. Optional.
- `predicate` <[Function]> receives the event data and resolves to truthy value when the waiting should resolve.
- - `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]<[Object]>>
Returns the event data value.
@@ -4433,7 +4414,9 @@ Waits for event to fire and passes its value into the predicate function. Return
### 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).
+
+<!-- TOC -->
[TimeoutError]: #class-timeouterror "TimeoutError"
@@ -4447,9 +4430,8 @@ Blink - Chromium's rendering engine - has a concept of "accessibility tree", whi
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 -->
+<!-- TOC -->
- [accessibility.snapshot([options])](#accessibilitysnapshotoptions)
-<!-- GEN:stop -->
#### accessibility.snapshot([options])
- `options` <[Object]>
@@ -4529,12 +4511,11 @@ for (const worker of page.workers())
console.log(' ' + worker.url());
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [worker.on('close')](#workeronclose)
- [worker.evaluate(pageFunction[, arg])](#workerevaluatepagefunction-arg)
- [worker.evaluateHandle(pageFunction[, arg])](#workerevaluatehandlepagefunction-arg)
- [worker.url()](#workerurl)
-<!-- GEN:stop -->
#### worker.on('close')
- type: <[Worker]>
@@ -4570,13 +4551,12 @@ If the function passed to the `worker.evaluateHandle` returns a [Promise], then
### class: BrowserServer
-<!-- GEN:toc -->
+<!-- TOC -->
- [browserServer.on('close')](#browserserveronclose)
- [browserServer.close()](#browserserverclose)
- [browserServer.kill()](#browserserverkill)
- [browserServer.process()](#browserserverprocess)
- [browserServer.wsEndpoint()](#browserserverwsendpoint)
-<!-- GEN:stop -->
#### browserServer.on('close')
@@ -4602,7 +4582,7 @@ 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.
[BrowserServer]: #class-browserserver "BrowserServer"
@@ -4622,14 +4602,13 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [browserType.connect(params)](#browsertypeconnectparams)
- [browserType.executablePath()](#browsertypeexecutablepath)
- [browserType.launch([options])](#browsertypelaunchoptions)
- [browserType.launchPersistentContext(userDataDir[, options])](#browsertypelaunchpersistentcontextuserdatadir-options)
- [browserType.launchServer([options])](#browsertypelaunchserveroptions)
- [browserType.name()](#browsertypename)
-<!-- GEN:stop -->
#### browserType.connect(params)
- `params` <[Object]>
@@ -4684,7 +4663,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
>
> 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.
@@ -4695,7 +4674,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
- `args` <[Array]<[string]>> Additional arguments to pass to the browser instance. The list of Chromium flags can be found [here](http://peter.sh/experiments/chromium-command-line-switches/).
- `bypassCSP` <[boolean]> Toggles bypassing page's Content-Security-Policy.
- `chromiumSandbox` <[boolean]> Enable Chromium sandboxing. Defaults to `true`.
- - `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`'.
- `deviceScaleFactor` <[number]> Specify device scale factor (can be thought of as dpr). Defaults to `1`.
- `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`.
- `downloadsPath` <[string]> If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed.
@@ -4721,16 +4700,16 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
- `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.
- `logger` <[Logger]> Logger sink for Playwright logging.
- `offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
- - `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.
- `proxy` <[Object]> Network proxy settings.
- `server` <[string]> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example `http://myproxy.com:3128` or `socks5://myproxy.com:3128`. Short form `myproxy.com:3128` is considered an HTTP proxy.
- `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.
- - `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.
@@ -4742,7 +4721,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
- `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.
- - `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.
- `viewport` <[null]|[Object]> Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `null` disables the default viewport.
- `width` <[number]> page width in pixels.
- `height` <[number]> page height in pixels.
@@ -4818,10 +4797,9 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
})();
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [logger.isEnabled(name, severity)](#loggerisenabledname-severity)
- [logger.log(name, severity, message, args, hints)](#loggerlogname-severity-message-args-hints)
-<!-- GEN:stop -->
#### logger.isEnabled(name, severity)
- `name` <[string]> logger name
@@ -4843,7 +4821,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'});
@@ -4851,13 +4829,10 @@ await page.goto('https://www.google.com');
await browser.stopTracing();
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [chromiumBrowser.newBrowserCDPSession()](#chromiumbrowsernewbrowsercdpsession)
- [chromiumBrowser.startTracing([page, options])](#chromiumbrowserstarttracingpage-options)
- [chromiumBrowser.stopTracing()](#chromiumbrowserstoptracing)
-<!-- GEN:stop -->
-
-<!-- GEN:toc-extends-Browser -->
- [browser.on('disconnected')](#browserondisconnected)
- [browser.close()](#browserclose)
- [browser.contexts()](#browsercontexts)
@@ -4865,7 +4840,6 @@ await browser.stopTracing();
- [browser.newContext([options])](#browsernewcontextoptions)
- [browser.newPage([options])](#browsernewpageoptions)
- [browser.version()](#browserversion)
-<!-- GEN:stop -->
#### chromiumBrowser.newBrowserCDPSession()
- returns: <[Promise]<[CDPSession]>>
@@ -4898,15 +4872,12 @@ Chromium-specific features including background pages, service worker support, e
const backgroundPage = await context.waitForEvent('backgroundpage');
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [chromiumBrowserContext.on('backgroundpage')](#chromiumbrowsercontextonbackgroundpage)
- [chromiumBrowserContext.on('serviceworker')](#chromiumbrowsercontextonserviceworker)
- [chromiumBrowserContext.backgroundPages()](#chromiumbrowsercontextbackgroundpages)
- [chromiumBrowserContext.newCDPSession(page)](#chromiumbrowsercontextnewcdpsessionpage)
- [chromiumBrowserContext.serviceWorkers()](#chromiumbrowsercontextserviceworkers)
-<!-- GEN:stop -->
-
-<!-- GEN:toc-extends-BrowserContext -->
- [browserContext.on('close')](#browsercontextonclose)
- [browserContext.on('page')](#browsercontextonpage)
- [browserContext.addCookies(cookies)](#browsercontextaddcookiescookies)
@@ -4931,7 +4902,6 @@ const backgroundPage = await context.waitForEvent('backgroundpage');
- [browserContext.storageState([options])](#browsercontextstoragestateoptions)
- [browserContext.unroute(url[, handler])](#browsercontextunrouteurl-handler)
- [browserContext.waitForEvent(event[, optionsOrPredicate])](#browsercontextwaitforeventevent-optionsorpredicate)
-<!-- GEN:stop -->
#### chromiumBrowserContext.on('backgroundpage')
- type: <[Page]>
@@ -4989,12 +4959,11 @@ const v8toIstanbul = require('v8-to-istanbul');
})();
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [chromiumCoverage.startCSSCoverage([options])](#chromiumcoveragestartcsscoverageoptions)
- [chromiumCoverage.startJSCoverage([options])](#chromiumcoveragestartjscoverageoptions)
- [chromiumCoverage.stopCSSCoverage()](#chromiumcoveragestopcsscoverage)
- [chromiumCoverage.stopJSCoverage()](#chromiumcoveragestopjscoverage)
-<!-- GEN:stop -->
#### chromiumCoverage.startCSSCoverage([options])
- `options` <[Object]>
@@ -5066,10 +5035,9 @@ await client.send('Animation.setPlaybackRate', {
});
```
-<!-- GEN:toc -->
+<!-- TOC -->
- [cdpSession.detach()](#cdpsessiondetach)
- [cdpSession.send(method[, params])](#cdpsessionsendmethod-params)
-<!-- GEN:stop -->
#### cdpSession.detach()
- returns: <[Promise]>
@@ -5088,7 +5056,7 @@ Detaches the CDPSession from the target. Once detached, the CDPSession object wo
Firefox browser instance does not expose Firefox-specific features.
-<!-- GEN:toc-extends-Browser -->
+<!-- TOC -->
- [browser.on('disconnected')](#browserondisconnected)
- [browser.close()](#browserclose)
- [browser.contexts()](#browsercontexts)
@@ -5096,7 +5064,6 @@ Firefox browser instance does not expose Firefox-specific features.
- [browser.newContext([options])](#browsernewcontextoptions)
- [browser.newPage([options])](#browsernewpageoptions)
- [browser.version()](#browserversion)
-<!-- GEN:stop -->
[FirefoxBrowser]: #class-firefoxbrowser "FirefoxBrowser"
@@ -5105,7 +5072,7 @@ Firefox browser instance does not expose Firefox-specific features.
WebKit browser instance does not expose WebKit-specific features.
-<!-- GEN:toc-extends-Browser -->
+<!-- TOC -->
- [browser.on('disconnected')](#browserondisconnected)
- [browser.close()](#browserclose)
- [browser.contexts()](#browsercontexts)
@@ -5113,7 +5080,6 @@ WebKit browser instance does not expose WebKit-specific features.
- [browser.newContext([options])](#browsernewcontextoptions)
- [browser.newPage([options])](#browsernewpageoptions)
- [browser.version()](#browserversion)
-<!-- GEN:stop -->
[WebKitBrowser]: #class-webkitbrowser "WebKitBrowser"
diff --git a/utils/doclint/cli.js b/utils/doclint/cli.js
index 149b10ebc3..4acbdf8ae5 100755
--- a/utils/doclint/cli.js
+++ b/utils/doclint/cli.js
@@ -26,6 +26,7 @@ const { spawnSync } = require('child_process');
const preprocessor = require('./preprocessor');
const { MDOutline } = require('./MDBuilder');
const missingDocs = require('./missingDocs');
+const Documentation = require('./Documentation');
/** @typedef {import('./Documentation').Type} Type */
/** @typedef {import('../markdown').MarkdownNode} MarkdownNode */
@@ -63,11 +64,6 @@ async function run() {
// Produce api.md
{
- const createMemberLink = (text) => {
- const anchor = text.toLowerCase().split(',').map(c => c.replace(/[^a-z]/g, '')).join('-');
- return `[\`${text}\`](#${anchor})`;
- };
-
outline.renderLinks(item => {
const { clazz, member, param, option } = item;
if (param)
@@ -101,6 +97,15 @@ async function run() {
});
// Append class comments
classNode.children = (clazz.spec || []).map(c => md.clone(c));
+ classNode.children.push({
+ type: 'text',
+ text: '<!-- TOC -->'
+ });
+ classNode.children.push(...generateToc(clazz));
+ if (clazz.extends && clazz.extends !== 'EventEmitter' && clazz.extends !== 'Error') {
+ const superClass = outline.documentation.classes.get(clazz.extends);
+ classNode.children.push(...generateToc(superClass));
+ }
for (const member of clazz.membersArray) {
// Iterate members
@@ -204,6 +209,57 @@ function getRepositoryFiles() {
return files.map(file => path.join(PROJECT_DIR, file));
}
+
+const memberLinks = new Map();
+const rMemberLinks = new Map();
+
+/**
+ * @param {string} text
+ */
+function createMemberLink(text) {
+ if (memberLinks.has(text))
+ return memberLinks.get(text);
+ const baseAnchor = text.toLowerCase().split(',').map(c => c.replace(/[^a-z]/g, '')).join('-');
+ let anchor = baseAnchor;
+ let index = 0;
+ while (rMemberLinks.has(anchor))
+ anchor = baseAnchor + '-' + (++index);
+ const result = `[${text}](#${anchor})`;
+ memberLinks.set(text, result);
+ rMemberLinks.set(anchor, text);
+ return result;
+};
+
+/**
+ * @param {Documentation.Class} clazz
+ * @return {MarkdownNode[]}
+ */
+function generateToc(clazz) {
+ /** @type {MarkdownNode[]} */
+ const result = [];
+ for (const member of clazz.membersArray) {
+ if (member.kind === 'property') {
+ result.push({
+ type: 'li',
+ liType: 'default',
+ text: createMemberLink(`${clazz.varName}.${member.name}`)
+ });
+ } else if (member.kind === 'event') {
+ result.push({
+ type: 'li',
+ liType: 'default',
+ text: createMemberLink(`${clazz.varName}.on('${member.name}')`)
+ });
+ } else if (member.kind === 'method') {
+ result.push({
+ type: 'li',
+ liType: 'default',
+ text: createMemberLink(`${clazz.varName}.${member.name}(${member.signature})`)
+ });
+ }
+ }
+ return result;
+}
/**
* @param {string} name
* @param {Type} type