diff --git a/docs-src/api-body.md b/docs-src/api-body.md index 88dd6561e6..3b5be7a366 100644 --- a/docs-src/api-body.md +++ b/docs-src/api-body.md @@ -132,7 +132,7 @@ Emitted when Browser context gets closed. This might happen because of one of th * The [`method: Browser.close`]() method was called. ## event: BrowserContext.page -- <[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 [`event: Page.popup`]() to receive events about popups relevant to a specific page. @@ -165,13 +165,13 @@ await browserContext.addCookies([cookieObject1, cookieObject2]); - `cookies` <[Array]<[Object]>> - `name` <[string]> **required** - `value` <[string]> **required** - - `url` <[string]> either url or domain / path are required - - `domain` <[string]> either url or domain / path are required - - `path` <[string]> either url or domain / path are required - - `expires` <[number]> Unix time in seconds. - - `httpOnly` <[boolean]> - - `secure` <[boolean]> - - `sameSite` <"Strict"|"Lax"|"None"> + - `url` <[string]> either url or domain / path are required. Optional. + - `domain` <[string]> either url or domain / path are required Optional. + - `path` <[string]> either url or domain / path are required Optional. + - `expires` <[number]> Unix time in seconds. Optional. + - `httpOnly` <[boolean]> Optional. + - `secure` <[boolean]> Optional. + - `sameSite` <"Strict"|"Lax"|"None"> Optional. ## async method: BrowserContext.addInitScript @@ -201,8 +201,8 @@ await browserContext.addInitScript({ ### param: BrowserContext.addInitScript.script - `script` <[function]|[string]|[Object]> - - `path` <[string]> Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. - - `content` <[string]> Raw script content. + - `path` <[string]> Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. Optional. + - `content` <[string]> Raw script content. Optional. Script to be evaluated in all pages in the browser context. @@ -372,24 +372,24 @@ specified. ### param: BrowserContext.grantPermissions.permissions - `permissions` <[Array]<[string]>> - - `'geolocation'` - - `'midi'` - - `'midi-sysex'` (system-exclusive midi) - - `'notifications'` - - `'push'` - - `'camera'` - - `'microphone'` - - `'background-sync'` - - `'ambient-light-sensor'` - - `'accelerometer'` - - `'gyroscope'` - - `'magnetometer'` - - `'accessibility-events'` - - `'clipboard-read'` - - `'clipboard-write'` - - `'payment-handler'` A permission or an array of permissions to grant. Permissions can be one of the following values: + * `'geolocation'` + * `'midi'` + * `'midi-sysex'` (system-exclusive midi) + * `'notifications'` + * `'push'` + * `'camera'` + * `'microphone'` + * `'background-sync'` + * `'ambient-light-sensor'` + * `'accelerometer'` + * `'gyroscope'` + * `'magnetometer'` + * `'accessibility-events'` + * `'clipboard-read'` + * `'clipboard-write'` + * `'payment-handler'` ### option: BrowserContext.grantPermissions.origin - `origin` <[string]> @@ -643,7 +643,7 @@ page.removeListener('request', logRequest); Emitted when the page closes. ## event: Page.console -- <[ConsoleMessage]> +- type: <[ConsoleMessage]> Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also emitted if the page throws an error or a warning. @@ -692,7 +692,7 @@ await new Promise((resolve, reject) => { ``` ## event: Page.dialog -- <[Dialog]> +- type: <[Dialog]> Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via [`method: Dialog.accept`]() or [`method: Dialog.dismiss`]() methods. @@ -703,7 +703,7 @@ Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/e event is dispatched. ## event: Page.download -- <[Download]> +- type: <[Download]> Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance. @@ -713,7 +713,7 @@ downloaded content. If `acceptDownloads` is not set or set to `false`, download download is not performed and user has no access to the downloaded files. ## event: Page.filechooser -- <[FileChooser]> +- type: <[FileChooser]> Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can respond to it via setting the input files using [`method: FileChooser.setFiles`]() that can be uploaded after that. @@ -725,17 +725,17 @@ page.on('filechooser', async (fileChooser) => { ``` ## event: Page.frameattached -- <[Frame]> +- type: <[Frame]> Emitted when a frame is attached. ## event: Page.framedetached -- <[Frame]> +- type: <[Frame]> Emitted when a frame is detached. ## event: Page.framenavigated -- <[Frame]> +- type: <[Frame]> Emitted when a frame is navigated to a new url. @@ -744,12 +744,12 @@ Emitted when a frame is navigated to a new url. Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched. ## event: Page.pageerror -- <[Error]> The exception message +- type: <[Error]> The exception message Emitted when an uncaught exception happens within the page. ## event: Page.popup -- <[Page]> Page corresponding to "popup" window +- type: <[Page]> Page corresponding to "popup" window Emitted when the page opens a new tab or window. This event is emitted in addition to the [`event: BrowserContext.page`](), but only for popups relevant to this page. @@ -770,13 +770,13 @@ console.log(await popup.evaluate('location.href')); need it in most cases). ## event: Page.request -- <[Request]> +- type: <[Request]> Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see [`method: Page.route`]() or [`method: BrowserContext.route`](). ## event: Page.requestfailed -- <[Request]> +- type: <[Request]> Emitted when a request fails, for example by timing out. @@ -784,24 +784,24 @@ Emitted when a request fails, for example by timing out. will complete with [`event: Page.requestfinished`]() event and not with [`event: Page.requestfailed`](). ## event: Page.requestfinished -- <[Request]> +- type: <[Request]> Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. ## event: Page.response -- <[Response]> +- type: <[Response]> Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. ## event: Page.websocket -- <[WebSocket]> websocket +- type: <[WebSocket]> websocket Emitted when <[WebSocket]> request is sent. ## event: Page.worker -- <[Worker]> +- type: <[Worker]> Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page. @@ -885,8 +885,8 @@ Function to be evaluated in browser context Optional argument to pass to [`param: pageFunction`]() -## namespace: Page.accessibility -- returns: <[Accessibility]> +## property: Page.accessibility +- type: <[Accessibility]> ## async method: Page.addInitScript @@ -913,8 +913,8 @@ await page.addInitScript(preloadFile); ### param: Page.addInitScript.script - `script` <[function]|[string]|[Object]> - - `path` <[string]> Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. - - `content` <[string]> Raw script content. + - `path` <[string]> Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. Optional. + - `content` <[string]> Raw script content. Optional. Script to be evaluated in the page. @@ -933,10 +933,10 @@ Shortcut for main frame's [`method: Frame.addScriptTag`](). ### param: Page.addScriptTag.params - `params` <[Object]> - - `url` <[string]> URL of a script to be added. - - `path` <[string]> Path to the JavaScript file to be injected into frame. If `path` is a relative path, then it is resolved relative to the current working directory. - - `content` <[string]> Raw JavaScript content to be injected into frame. - - `type` <[string]> Script type. Use 'module' in order to load a Javascript ES6 module. See [script](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) for more details. + - `url` <[string]> URL of a script to be added. Optional. + - `path` <[string]> Path to the JavaScript file to be injected into frame. If `path` is a relative path, then it is resolved relative to the current working directory. Optional. + - `content` <[string]> Raw JavaScript content to be injected into frame. Optional. + - `type` <[string]> Script type. Use 'module' in order to load a Javascript ES6 module. See [script](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) for more details. Optional. ## async method: Page.addStyleTag - returns: <[ElementHandle]> @@ -948,9 +948,9 @@ Shortcut for main frame's [`method: Frame.addStyleTag`](). ### param: Page.addStyleTag.params - `params` <[Object]> - - `url` <[string]> URL of the `` tag. - - `path` <[string]> Path to the CSS file to be injected into frame. If `path` is a relative path, then it is resolved relative to the current working directory. - - `content` <[string]> Raw CSS content to be injected into frame. + - `url` <[string]> URL of the `` tag. Optional. + - `path` <[string]> Path to the CSS file to be injected into frame. If `path` is a relative path, then it is resolved relative to the current working directory. Optional. + - `content` <[string]> Raw CSS content to be injected into frame. Optional. ## async method: Page.bringToFront @@ -1039,8 +1039,8 @@ Gets the full HTML contents of the page, including the doctype. Get the browser context that the page belongs to. -## namespace: Page.coverage -- returns: <[null]|[ChromiumCoverage]> +## property: Page.coverage +- type: <[null]|[ChromiumCoverage]> Browser-specific Coverage implementation, only available for Chromium atm. See [ChromiumCoverage](#class-chromiumcoverage) for more details. @@ -1155,13 +1155,13 @@ await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').ma ### param: Page.emulateMedia.params - `params` <[Object]> - - `media` <[null]|"screen"|"print"> Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`. Passing `null` disables CSS media emulation. Omitting `media` or passing `undefined` does not change the emulated value. - - `colorScheme` <[null]|"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing `null` disables color scheme emulation. Omitting `colorScheme` or passing `undefined` does not change the emulated value. + - `media` <[null]|"screen"|"print"> Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`. Passing `null` disables CSS media emulation. Omitting `media` or passing `undefined` does not change the emulated value. Optional. + - `colorScheme` <[null]|"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing `null` disables color scheme emulation. Omitting `colorScheme` or passing `undefined` does not change the emulated value. Optional. ## async method: Page.evaluate - returns: <[Serializable]> -Returns the value of the [`param: pageFunction`]() invacation. +Returns the value of the [`param: pageFunction`]() invocation. If the function passed to the `page.evaluate` returns a [Promise], then `page.evaluate` would wait for the promise to resolve and return its value. @@ -1210,7 +1210,7 @@ Optional argument to pass to [`param: pageFunction`]() ## async method: Page.evaluateHandle - returns: <[JSHandle]> -Returns the value of the [`param: pageFunction`]() invacation as in-page object (JSHandle). +Returns the value of the [`param: pageFunction`]() invocation as in-page object (JSHandle). The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page object (JSHandle). @@ -1432,8 +1432,8 @@ const frame = page.frame({ url: /.*domain.*/ }); ### param: Page.frame.frameSelector - `frameSelector` <[string]|[Object]> - - `name` <[string]> frame name specified in the `iframe`'s `name` attribute - - `url` <[string]|[RegExp]|[Function]> A glob pattern, regex pattern or predicate receiving frame's `url` as a [URL] object. + - `name` <[string]> Frame name specified in the `iframe`'s `name` attribute. Optional. + - `url` <[string]|[RegExp]|[Function]> A glob pattern, regex pattern or predicate receiving frame's `url` as a [URL] object. Optional. Frame name or other frame lookup options. @@ -1566,16 +1566,16 @@ Returns `element.innerText`. Indicates that the page has been closed. -## namespace: Page.keyboard -- returns: <[Keyboard]> +## property: Page.keyboard +- type: <[Keyboard]> ## method: Page.mainFrame - returns: <[Frame]> The page's main frame. Page is guaranteed to have a main frame which persists during navigations. -## namespace: Page.mouse -- returns: <[Mouse]> +## property: Page.mouse +- type: <[Mouse]> ## async method: Page.opener - returns: <[null]|[Page]> @@ -1651,14 +1651,14 @@ Display header and footer. Defaults to `false`. ### option: Page.pdf.headerTemplate - `headerTemplate` <[string]> - - `'date'` formatted print date - - `'title'` document title - - `'url'` document location - - `'pageNumber'` current page number - - `'totalPages'` total pages in the document HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: + * `'date'` formatted print date + * `'title'` document title + * `'url'` document location + * `'pageNumber'` current page number + * `'totalPages'` total pages in the document ### option: Page.pdf.footerTemplate - `footerTemplate` <[string]> @@ -1722,7 +1722,7 @@ generate the text for. A superset of the [`param: key`]() values can be found `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc. -Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. +Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. Holding down `Shift` will type the text that corresponds to the [`param: key`]() in the upper case. @@ -1885,9 +1885,9 @@ Shortcut for main frame's [`method: Frame.selectOption`]() ### param: Page.selectOption.values - `values` <[null]|[string]|[ElementHandle]|[Array]<[string]>|[Object]|[Array]<[ElementHandle]>|[Array]<[Object]>> - - `value` <[string]> Matches by `option.value`. - - `label` <[string]> Matches by `option.label`. - - `index` <[number]> Matches by the index. + - `value` <[string]> Matches by `option.value`. Optional. + - `label` <[string]> Matches by `option.label`. Optional. + - `index` <[number]> Matches by the index. Optional. Options to select. If the `