docs: python api review (#4986)

This commit is contained in:
Pavel Feldman 2021-01-12 12:14:27 -08:00 committed by GitHub
parent 3d258631b1
commit cac119f3bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 357 additions and 251 deletions

View File

@ -46,9 +46,11 @@ assistive technologies themselves. By default, Playwright tries to approximate t
Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
page.
> **NOTE** The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
:::note
The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
Playwright will discard them as well for an easier to process tree, unless [`option: interestingOnly`] is set to
`false`.
:::
An example of dumping the entire accessibility tree:

View File

@ -14,9 +14,6 @@ const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
})();
```
See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific features. Note that
[`method: BrowserType.launch`] always returns a specific browser instance, based on the browser being launched.
## event: Browser.disconnected
Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:

View File

@ -44,8 +44,10 @@ const [page] = await Promise.all([
console.log(await page.evaluate('location.href'));
```
> **NOTE** Use [`method: Page.waitForLoadState`] to wait until the page gets to a particular state (you should not
:::note
Use [`method: Page.waitForLoadState`] to wait until the page gets to a particular state (you should not
need it in most cases).
:::
## async method: BrowserContext.addCookies
@ -91,8 +93,10 @@ await browserContext.addInitScript({
});
```
> **NOTE** The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
:::note
The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
[`method: Page.addInitScript`] is not defined.
:::
### param: BrowserContext.addInitScript.script
* langs: js
@ -132,7 +136,9 @@ context.clearPermissions();
Closes the browser context. All the pages that belong to the browser context will be closed.
> **NOTE** the default browser context cannot be closed.
:::note
The default browser context cannot be closed.
:::
## async method: BrowserContext.cookies
- returns: <[Array]<[Object]>>
@ -332,7 +338,9 @@ await browser.close();
Page routes (set up with [`method: Page.route`]) take precedence over browser context routes when request matches both
handlers.
> **NOTE** Enabling routing disables http cache.
:::note
Enabling routing disables http cache.
:::
### param: BrowserContext.route.url
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
@ -354,8 +362,10 @@ This setting will change the default maximum navigation time for the following m
* [`method: Page.setContent`]
* [`method: Page.waitForNavigation`]
> **NOTE** [`method: Page.setDefaultNavigationTimeout`] and [`method: Page.setDefaultTimeout`] take priority over
:::note
[`method: Page.setDefaultNavigationTimeout`] and [`method: Page.setDefaultTimeout`] take priority over
[`method: BrowserContext.setDefaultNavigationTimeout`].
:::
### param: BrowserContext.setDefaultNavigationTimeout.timeout
- `timeout` <[float]>
@ -366,8 +376,10 @@ Maximum navigation time in milliseconds
This setting will change the default maximum time for all the methods accepting [`param: timeout`] option.
> **NOTE** [`method: Page.setDefaultNavigationTimeout`], [`method: Page.setDefaultTimeout`] and [`method:
:::note
[`method: Page.setDefaultNavigationTimeout`], [`method: Page.setDefaultTimeout`] and [`method:
BrowserContext.setDefaultNavigationTimeout`] take priority over [`method: BrowserContext.setDefaultTimeout`].
:::
### param: BrowserContext.setDefaultTimeout.timeout
- `timeout` <[float]>
@ -380,7 +392,9 @@ The extra HTTP headers will be sent with every request initiated by any page in
with page-specific extra HTTP headers set with [`method: Page.setExtraHTTPHeaders`]. If page overrides a particular
header, page-specific header value will be used instead of the browser context header value.
> **NOTE** `browserContext.setExtraHTTPHeaders` does not guarantee the order of headers in the outgoing requests.
:::note
[`method: BrowserContext.setExtraHTTPHeaders`] does not guarantee the order of headers in the outgoing requests.
:::
### param: BrowserContext.setExtraHTTPHeaders.headers
- `headers` <[Object]<[string], [string]>>
@ -395,8 +409,10 @@ Sets the context's geolocation. Passing `null` or `undefined` emulates position
await browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});
```
> **NOTE** Consider using [`method: BrowserContext.grantPermissions`] to grant permissions for the browser context
:::note
Consider using [`method: BrowserContext.grantPermissions`] to grant permissions for the browser context
pages to read its geolocation.
:::
### param: BrowserContext.setGeolocation.geolocation
- `geolocation` <[null]|[Object]>
@ -405,6 +421,7 @@ pages to read its geolocation.
- `accuracy` <[float]> Non-negative accuracy value. Defaults to `0`.
## async method: BrowserContext.setHTTPCredentials
* langs: js
**DEPRECATED** Browsers may cache credentials after successful authentication.
Create a new browser context instead.
@ -481,8 +498,8 @@ Event name, same one would pass into `browserContext.on(event)`.
### param: BrowserContext.waitForEvent.optionsOrPredicate
* langs: js
- `optionsOrPredicate` <[Function]|[Object]>
- `predicate` <[Function]> receives the event data and resolves to truthy value when the waiting should resolve.
- `optionsOrPredicate` <[function]|[Object]>
- `predicate` <[function]> receives the event data and resolves to truthy value when the waiting should resolve.
- `timeout` <[float]> 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 [`method: BrowserContext.setDefaultTimeout`].
Either a predicate that receives an event or an options object. Optional.

View File

@ -14,7 +14,9 @@ await browser.stopTracing();
[ChromiumBrowser] can also be used for testing Chrome Extensions.
> **NOTE** Extensions in Chrome / Chromium currently only work in non-headless mode.
:::note
Extensions in Chrome / Chromium currently only work in non-headless mode.
:::
The following is code for getting a handle to the [background page](https://developer.chrome.com/extensions/background_pages) of an extension whose source is located in `./my-extension`:
```js

View File

@ -12,7 +12,9 @@ const backgroundPage = await context.waitForEvent('backgroundpage');
Emitted when new background page is created in the context.
> **NOTE** Only works with persistent context.
:::note
Only works with persistent context.
:::
## event: ChromiumBrowserContext.serviceworker
- type: <[Worker]>

View File

@ -38,9 +38,11 @@ Whether to reset coverage on every navigation. Defaults to `true`.
Returns coverage is started
> **NOTE** Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created
:::note
Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created
on the page using `eval` or `new Function`. If [`option: reportAnonymousScripts`] is set to `true`, anonymous scripts
will have `__playwright_evaluation_script__` as their URL.
:::
### option: ChromiumCoverage.startJSCoverage.resetOnNavigation
- `resetOnNavigation` <[boolean]>
@ -62,7 +64,9 @@ Whether anonymous scripts generated by the page should be reported. Defaults to
Returns the array of coverage reports for all stylesheets
> **NOTE** CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
:::note
CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
:::
## async method: ChromiumCoverage.stopJSCoverage
- returns: <[Array]<[Object]>>
@ -79,5 +83,7 @@ Returns the array of coverage reports for all stylesheets
Returns the array of coverage reports for all scripts
> **NOTE** JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are
:::note
JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are
reported.
:::

View File

@ -17,9 +17,12 @@ const path = await download.path();
...
```
> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
download is not performed and user has no access to the downloaded files.
:::note
Browser context **must** be created with the [`option: acceptDownloads`] set to `true` when user needs access to the
downloaded content. If [`option: acceptDownloads`] is not set, download events are
emitted, but the actual download is not performed and user has no access to the
downloaded files.
:::
## async method: Download.createReadStream
* langs: js
@ -37,7 +40,7 @@ Deletes the downloaded file.
Returns download error if any.
## async method: Download.path
- returns: <[null]|[string]>
- returns: <[null]|[path]>
Returns path to the downloaded file in case of successful download.

View File

@ -210,7 +210,9 @@ If the element is detached from the DOM at any moment during the action, this me
When all steps combined have not finished during the specified [`option: timeout`], this method rejects with a
[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::note
`elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::
### option: ElementHandle.dblclick.button = %%-input-button-%%
@ -502,7 +504,9 @@ If the element is detached from the DOM at any moment during the action, this me
When all steps combined have not finished during the specified [`option: timeout`], this method rejects with a
[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
:::note
`elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
:::
### option: ElementHandle.tap.position = %%-input-position-%%
@ -613,7 +617,9 @@ const div = await page.$('div');
const span = await div.waitForSelector('span', { state: 'attached' });
```
> **NOTE** This method does not work across navigations, use [`method: Page.waitForSelector`] instead.
:::note
This method does not work across navigations, use [`method: Page.waitForSelector`] instead.
:::
### param: ElementHandle.waitForSelector.selector = %%-query-selector-%%

View File

@ -251,7 +251,9 @@ This method double clicks an element matching [`param: selector`] by performing
When all steps combined have not finished during the specified [`option: timeout`], this method rejects with a
[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::note
`frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::
### param: Frame.dblclick.selector = %%-input-selector-%%
@ -476,10 +478,14 @@ last redirect.
"Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling [`method:
Response.status`].
> **NOTE** `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation
:::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
:::
:::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).
:::
### param: Frame.goto.url
- `url` <[string]>
@ -602,8 +608,10 @@ Returns frame's name attribute as specified in the tag.
If the name is empty, returns the id attribute instead.
> **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed
:::note
This value is calculated once when the frame is created, and will not update if the attribute is changed
later.
:::note
## method: Frame.page
- returns: <[Page]>
@ -714,7 +722,9 @@ This method taps an element matching [`param: selector`] by performing the follo
When all steps combined have not finished during the specified [`option: timeout`], this method rejects with a
[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
:::note
`frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
:::
### param: Frame.tap.selector = %%-input-selector-%%
@ -876,8 +886,10 @@ 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
:::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.
:::
### option: Frame.waitForNavigation.timeout = %%-navigation-timeout-%%

View File

@ -106,5 +106,7 @@ property to get
Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
> **NOTE** The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
:::note
The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
error if the object has circular references.
:::

View File

@ -64,7 +64,9 @@ After the key is pressed once, subsequent calls to [`method: Keyboard.down`] wil
[repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
[`method: Keyboard.up`].
> **NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
:::note
Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
:::
### param: Keyboard.down.key
- `key` <[string]>
@ -79,7 +81,9 @@ Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress
page.keyboard.insertText('嗨');
```
> **NOTE** Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
:::note
Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
:::
### param: Keyboard.insertText.text
- `text` <[string]>
@ -141,7 +145,9 @@ await page.keyboard.type('Hello'); // Types instantly
await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
```
> **NOTE** Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
:::note
Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
:::
### param: Keyboard.type.text
- `text` <[string]>

View File

@ -111,9 +111,12 @@ event is dispatched.
Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
[Download] instance.
> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
download is not performed and user has no access to the downloaded files.
:::note
Browser context **must** be created with the [`option: acceptDownloads`] set to `true` when user needs access to the
downloaded content. If [`option: acceptDownloads`] is not set, download events
are emitted, but the actual download is not performed and user has no access to
the downloaded files.
:::
## event: Page.filechooser
- type: <[FileChooser]>
@ -169,8 +172,10 @@ const [popup] = await Promise.all([
console.log(await popup.evaluate('location.href'));
```
> **NOTE** Use [`method: Page.waitForLoadState`] to wait until the page gets to a particular state (you should not
:::note
Use [`method: Page.waitForLoadState`] to wait until the page gets to a particular state (you should not
need it in most cases).
:::
## event: Page.request
- type: <[Request]>
@ -183,8 +188,10 @@ Emitted when a page issues a request. The [request] object is read-only. In orde
Emitted when a request fails, for example by timing out.
> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
:::note
HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
will complete with [`event: Page.requestfinished`] event and not with [`event: Page.requestfailed`].
:::
## event: Page.requestfinished
- type: <[Request]>
@ -321,8 +328,10 @@ const preloadFile = fs.readFileSync('./preload.js', 'utf8');
await page.addInitScript(preloadFile);
```
> **NOTE** The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
:::note
The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
[`method: Page.addInitScript`] is not defined.
:::
### param: Page.addInitScript.script
* langs: js
@ -457,8 +466,9 @@ close.
By default, `page.close()` **does not** run `beforeunload` handlers.
> **NOTE** if [`option: runBeforeUnload`] is passed as true, a `beforeunload` dialog might be summoned
> and should be handled manually via [`event: Page.dialog`] event.
:::note
if [`option: runBeforeUnload`] is passed as true, a `beforeunload` dialog might be summoned and should be handled manually via [`event: Page.dialog`] event.
:::
### option: Page.close.runBeforeUnload
- `runBeforeUnload` <[boolean]>
@ -495,7 +505,9 @@ This method double clicks an element matching [`param: selector`] by performing
When all steps combined have not finished during the specified [`option: timeout`], this method rejects with a
[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::note
`page.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::
Shortcut for main frame's [`method: Frame.dblclick`].
@ -695,7 +707,9 @@ browserContext: BrowserContext, page: Page, frame: Frame }`.
See [`method: BrowserContext.exposeBinding`] for the context-wide version.
> **NOTE** Functions installed via `page.exposeBinding` survive navigations.
:::note
Functions installed via [`method: Page.exposeBinding`] survive navigations.
:::
An example of exposing page URL to all frames in a page:
@ -761,7 +775,9 @@ If the [`param: callback`] returns a [Promise], it will be awaited.
See [`method: BrowserContext.exposeFunction`] for context-wide exposed function.
> **NOTE** Functions installed via `page.exposeFunction` survive navigations.
:::note
Functions installed via [`method: Page.exposeFunction`] survive navigations.
:::
An example of adding an `md5` function to the page:
@ -939,10 +955,14 @@ last redirect.
Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling [`method:
Response.status`].
> **NOTE** `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
:::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
:::
:::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 [`method: Frame.goto`]
@ -1083,15 +1103,18 @@ Returns the opener for popup pages and `null` for others. If the opener has been
Returns the PDF buffer.
> **NOTE** Generating a pdf is currently only supported in Chromium headless.
:::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 [`method:
Page.emulateMedia`] before calling `page.pdf()`:
> **NOTE** By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
:::note
By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
[`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to
force rendering of exact colors.
:::
```js
// Generates a PDF with 'screen' media type.
await page.emulateMedia({media: 'screen'});
@ -1125,9 +1148,11 @@ The [`option: format`] options are:
* `A5`: 5.83in x 8.27in
* `A6`: 4.13in x 5.83in
> **NOTE** [`option: headerTemplate`] and [`option: footerTemplate`] markup have the following limitations:
:::note
[`option: headerTemplate`] and [`option: footerTemplate`] markup have the following limitations:
> 1. Script tags inside templates are not evaluated.
> 2. Page styles are not visible inside templates.
:::
### option: Page.pdf.path
- `path` <[path]>
@ -1272,7 +1297,9 @@ Routing provides the capability to modify network requests that are made by a pa
Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
> **NOTE** The handler will only be called for the first url if the response is a redirect.
:::note
The handler will only be called for the first url if the response is a redirect.
:::
An example of a naïve handler that aborts all image requests:
@ -1295,7 +1322,9 @@ await browser.close();
Page routes take precedence over browser context routes (set up with [`method: BrowserContext.route`]) when request
matches both handlers.
> **NOTE** Enabling routing disables http cache.
:::note
Enabling routing disables http cache.
:::
### param: Page.route.url
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
@ -1312,8 +1341,10 @@ handler function to route the request.
Returns the buffer with the captured screenshot.
> **NOTE** Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for
:::note
Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for
discussion.
:::
### option: Page.screenshot.path
- `path` <[path]>
@ -1403,8 +1434,10 @@ This setting will change the default maximum navigation time for the following m
* [`method: Page.setContent`]
* [`method: Page.waitForNavigation`]
> **NOTE** [`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`],
:::note
[`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`],
[`method: BrowserContext.setDefaultTimeout`] and [`method: BrowserContext.setDefaultNavigationTimeout`].
:::
### param: Page.setDefaultNavigationTimeout.timeout
- `timeout` <[float]>
@ -1415,7 +1448,9 @@ Maximum navigation time in milliseconds
This setting will change the default maximum time for all the methods accepting [`param: timeout`] option.
> **NOTE** [`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`].
:::note
[`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`].
:::
### param: Page.setDefaultTimeout.timeout
- `timeout` <[float]>
@ -1426,7 +1461,9 @@ Maximum time in milliseconds
The extra HTTP headers will be sent with every request the page initiates.
> **NOTE** page.setExtraHTTPHeaders does not guarantee the order of headers in the outgoing requests.
:::note
[`method: Page.setExtraHTTPHeaders`] does not guarantee the order of headers in the outgoing requests.
:::
### param: Page.setExtraHTTPHeaders.headers
- `headers` <[Object]<[string], [string]>>
@ -1483,7 +1520,9 @@ This method taps an element matching [`param: selector`] by performing the follo
When all steps combined have not finished during the specified [`option: timeout`], this method rejects with a
[TimeoutError]. Passing zero timeout disables this.
> **NOTE** `page.tap()` requires that the `hasTouch` option of the browser context be set to true.
:::note
[`method: Page.tap`] requires that the [`option: hasTouch`] option of the browser context be set to true.
:::
Shortcut for main frame's [`method: Frame.tap`].
@ -1612,8 +1651,8 @@ value. Will throw an error if the page is closed before the event is fired.
### param: Page.waitForEvent.optionsOrPredicate
* langs: js
- `optionsOrPredicate` <[Function]|[Object]>
- `predicate` <[Function]> receives the event data and resolves to truthy value when the waiting should resolve.
- `optionsOrPredicate` <[function]|[Object]>
- `predicate` <[function]> receives the event data and resolves to truthy value when the waiting should resolve.
- `timeout` <[float]> 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 [`method: BrowserContext.setDefaultTimeout`].
Either a predicate that receives an event or an options object. Optional.
@ -1711,8 +1750,10 @@ 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
:::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 [`method: Frame.waitForNavigation`].
@ -1831,4 +1872,6 @@ A timeout to wait for
This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
associated with the page.
> **NOTE** This does not contain ServiceWorkers
:::note
This does not contain ServiceWorkers
:::

View File

@ -24,7 +24,7 @@ This object can be used to launch or connect to Chromium, returning instances of
## property: Playwright.devices
- type: <[Object]>
Returns a list of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`]. Actual list of devices can be found in [src/server/deviceDescriptors.ts](https://github.com/Microsoft/playwright/blob/master/src/server/deviceDescriptors.ts).
Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
```js
const { webkit, devices } = require('playwright');

View File

@ -8,8 +8,10 @@ Whenever the page sends a request for a network resource the following sequence
If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event),
the [`event: Page.requestfailed`] event is emitted.
> **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
:::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.

View File

@ -7,7 +7,7 @@ console.log(await page.video().path());
```
## async method: Video.path
- returns: <[string]>
- returns: <[path]>
Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem
upon closing the browser context.

View File

@ -48,8 +48,8 @@ Event name, same one would pass into `webSocket.on(event)`.
### param: WebSocket.waitForEvent.optionsOrPredicate
* langs: js
- `optionsOrPredicate` <[Function]|[Object]>
- `predicate` <[Function]> receives the event data and resolves to truthy value when the waiting should resolve.
- `optionsOrPredicate` <[function]|[Object]>
- `predicate` <[function]> receives the event data and resolves to truthy value when the waiting should resolve.
- `timeout` <[float]> 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 [`method: BrowserContext.setDefaultTimeout`].
Either a predicate that receives an event or an options object. Optional.

View File

@ -154,7 +154,7 @@ Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `no_
* langs: python
- `noViewport` <[boolean]>
Disables the default viewport.
Does not enforce fixed viewport, allows resizing window in the headed mode.
## context-option-useragent
- `userAgent` <[string]>
@ -236,11 +236,13 @@ Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`
Logger sink for Playwright logging.
## context-option-videospath
* langs: js
- `videosPath` <[path]>
**DEPRECATED** Use [`option: recordVideo`] instead.
## context-option-videosize
* langs: js
- `videoSize` <[Object]>
- `width` <[int]> Video frame width.
- `height` <[int]> Video frame height.
@ -330,7 +332,7 @@ A glob pattern, regex pattern or predicate receiving [URL] to match while waitin
## wait-for-event-event
- `event` <[string]>
Event name, same one typically passed into `page.on(event)`.
Event name, same one typically passed into `*.on(event)`.
## wait-for-load-state-state
- `state` <"load"|"domcontentloaded"|"networkidle">
@ -369,7 +371,7 @@ only the first option matching one of the passed options is selected. Optional.
## python-wait-for-event-predicate
* langs: python
- `predicate` <[Function]>
- `predicate` <[function]>
Receives the event data and resolves to truthy value when the waiting should resolve.

View File

@ -149,15 +149,15 @@ event's value into the `predicate` function and waits for `predicate(event)` to
Will throw an error if browser context is closed before the `event` is fired.
```python async
async with context.expect_event(event_name) as event_info:
async with context.expect_event("page") as event_info:
await context.click("button")
value = await event_info.value
page = await event_info.value
```
```python sync
with context.expect_event(event_name) as event_info:
with context.expect_event("page") as event_info:
context.click("button")
value = event_info.value
page = event_info.value
```
### param: BrowserContext.expectEvent.event = %%-wait-for-event-event-%%
@ -188,52 +188,6 @@ value = event_info.value
### option: WebSocket.expectEvent.predicate = %%-python-wait-for-event-predicate-%%
### option: WebSocket.expectEvent.timeout = %%-python-wait-for-event-timeout-%%
## async method: Page.expectLoadState
* langs: python
- returns: <[EventContextManager]>
Performs action and waits for the required load state. It resolves when the page reaches a required load state, `load` by default. The navigation must have been committed when this method is called. If current document has
already reached the required state, resolves immediately.
```python async
async with page.expect_load_state():
await page.click('button') # Click triggers navigation.
# Context manager waits for 'load' event.
```
```python sync
with page.expect_load_state():
page.click('button') # Click triggers navigation.
# Context manager waits for 'load' event.
```
Shortcut for main frame's [`method: Frame.expectLoadState`].
### param: Page.expectLoadState.state = %%-wait-for-load-state-state-%%
### option: Page.expectLoadState.timeout = %%-navigation-timeout-%%
## async method: Frame.expectLoadState
* langs: python
- returns: <[EventContextManager]>
Performs action and waits for the required load state. It resolves when the page reaches a required load state, `load` by default. The navigation must have been committed when this method is called. If current document has
already reached the required state, resolves immediately.
```python async
async with frame.expect_load_state():
await frame.click('button') # Click triggers navigation.
# Context manager waits for 'load' event.
```
```python sync
with frame.expect_load_state():
frame.click('button') # Click triggers navigation.
# Context manager waits for 'load' event.
```
### param: Frame.expectLoadState.state = %%-wait-for-load-state-state-%%
### option: Frame.expectLoadState.timeout = %%-navigation-timeout-%%
## async method: Page.expectNavigation
* langs: python
- returns: <[EventContextManager]>
@ -258,8 +212,9 @@ with page.expect_navigation():
# Context manager waited for the navigation to happen.
```
**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the
URL is considered a navigation.
:::note
Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.
:::
Shortcut for main frame's [`method: Frame.expectNavigation`].
@ -291,8 +246,10 @@ with frame.expect_navigation():
# Context manager waited for the navigation to happen.
```
**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the
:::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.
:::
### option: Frame.expectNavigation.timeout = %%-navigation-timeout-%%
### option: Frame.expectNavigation.url = %%-wait-for-navigation-url-%%

View File

@ -58,7 +58,9 @@ $ docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_pr
]
```
> **NOTE**: Using `--ipc=host` is recommended when using Chrome ([Docker docs](https://docs.docker.com/engine/reference/run/#ipc-settings---ipc)). Chrome can run out of memory without this flag.
:::note
Using `--ipc=host` is recommended when using Chrome ([Docker docs](https://docs.docker.com/engine/reference/run/#ipc-settings---ipc)). Chrome can run out of memory without this flag.
:::
### Using on CI

View File

@ -317,7 +317,9 @@ page.type('#area', 'Hello World!')
This method will emit all the necessary keyboard events, with all the `keydown`, `keyup`, `keypress` events in place. You can even specify the optional `delay` between the key presses to simulate real user behavior.
> **NOTE** that most of the time, [`method: Page.fill`] will just work. You only need to type characters if there is special keyboard handling on the page.
:::note
Most of the time, [`method: Page.fill`] will just work. You only need to type characters if there is special keyboard handling on the page.
:::
#### API reference

View File

@ -61,7 +61,9 @@ $ npm i -D playwright
Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions.
> **NOTE** Developers can opt-in in this mode via exporting `PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers` in their `.bashrc`.
:::note
Developers can opt-in in this mode via exporting `PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers` in their `.bashrc`.
:::
## Download from artifact repository
@ -111,7 +113,9 @@ Playwright ships three packages that bundle only a single browser:
- [`playwright-webkit`](https://www.npmjs.com/package/playwright-webkit)
- [`playwright-firefox`](https://www.npmjs.com/package/playwright-firefox)
> **NOTE** All configuration environment variables also apply to these packages.
:::note
All configuration environment variables also apply to these packages.
:::
Using these packages is as easy as using a regular Playwright:

View File

@ -26,14 +26,14 @@ from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("http://webkit.org")
page.goto("http://playwright.dev")
print(page.title())
browser.close()
```
Playwright supports two variations of the API: synchronous are asynchronous. If your modern project uses [asyncio](https://docs.python.org/3/library/asyncio.html), you should use async API:
Playwright supports two variations of the API: synchronous and asynchronous. If your modern project uses [asyncio](https://docs.python.org/3/library/asyncio.html), you should use async API:
```py
```python
import asyncio
from playwright.async_api import async_playwright
@ -41,7 +41,7 @@ async def main():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
await page.goto("http://webkit.org")
await page.goto("http://playwright.dev")
print(await page.title())
await browser.close()
@ -52,7 +52,7 @@ asyncio.run(main())
In our first script, we will navigate to `whatsmyuseragent.org` and take a screenshot in WebKit.
```py
```python
from playwright.sync_api import sync_playwright
with sync_playwright() as p:

View File

@ -40,7 +40,7 @@ const [ download ] = await Promise.all([
const path = await download.path();
```
For every attachment downloaded by the page, [`event: Page.download`] event is emitted. If you create a browser context with the `acceptDownloads: true`, all these attachments are going to be downloaded into a temporary folder. You can obtain the download url, file system path and payload stream using the [Download] object from the event.
For every attachment downloaded by the page, [`event: Page.download`] event is emitted. If you create a browser context with the [`option: acceptDownloads`] set, all these attachments are going to be downloaded into a temporary folder. You can obtain the download url, file system path and payload stream using the [Download] object from the event.
#### Variations

230
types/types.d.ts vendored
View File

@ -295,7 +295,9 @@ export interface Page {
* [browserContext.exposeBinding()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextexposebinding)
* for the context-wide version.
*
* > **NOTE** Functions installed via `page.exposeBinding` survive navigations.
* > NOTE: Functions installed via
* [page.exposeBinding()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageexposebinding) survive
* navigations.
*
* An example of exposing page URL to all frames in a page:
*
@ -415,9 +417,9 @@ export interface Page {
* Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
* [Download] instance.
*
* > **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
* download is not performed and user has no access to the downloaded files.
* > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
* performed and user has no access to the downloaded files.
*/
on(event: 'download', listener: (download: Download) => void): this;
@ -478,7 +480,7 @@ export interface Page {
* console.log(await popup.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -494,8 +496,8 @@ export interface Page {
/**
* 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
* > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
* complete with
* [page.on('requestfinished')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfinished)
* event and not with
* [page.on('requestfailed')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfailed).
@ -599,9 +601,9 @@ export interface Page {
* Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
* [Download] instance.
*
* > **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
* download is not performed and user has no access to the downloaded files.
* > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
* performed and user has no access to the downloaded files.
*/
once(event: 'download', listener: (download: Download) => void): this;
@ -662,7 +664,7 @@ export interface Page {
* console.log(await popup.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -678,8 +680,8 @@ export interface Page {
/**
* 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
* > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
* complete with
* [page.on('requestfinished')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfinished)
* event and not with
* [page.on('requestfailed')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfailed).
@ -783,9 +785,9 @@ export interface Page {
* Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
* [Download] instance.
*
* > **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
* download is not performed and user has no access to the downloaded files.
* > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
* performed and user has no access to the downloaded files.
*/
addListener(event: 'download', listener: (download: Download) => void): this;
@ -846,7 +848,7 @@ export interface Page {
* console.log(await popup.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -862,8 +864,8 @@ export interface Page {
/**
* 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
* > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
* complete with
* [page.on('requestfinished')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfinished)
* event and not with
* [page.on('requestfailed')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfailed).
@ -967,9 +969,9 @@ export interface Page {
* Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
* [Download] instance.
*
* > **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
* download is not performed and user has no access to the downloaded files.
* > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
* performed and user has no access to the downloaded files.
*/
removeListener(event: 'download', listener: (download: Download) => void): this;
@ -1030,7 +1032,7 @@ export interface Page {
* console.log(await popup.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -1046,8 +1048,8 @@ export interface Page {
/**
* 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
* > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
* complete with
* [page.on('requestfinished')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfinished)
* event and not with
* [page.on('requestfailed')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfailed).
@ -1151,9 +1153,9 @@ export interface Page {
* Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
* [Download] instance.
*
* > **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
* download is not performed and user has no access to the downloaded files.
* > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
* performed and user has no access to the downloaded files.
*/
off(event: 'download', listener: (download: Download) => void): this;
@ -1214,7 +1216,7 @@ export interface Page {
* console.log(await popup.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -1230,8 +1232,8 @@ export interface Page {
/**
* 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
* > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
* complete with
* [page.on('requestfinished')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfinished)
* event and not with
* [page.on('requestfailed')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfailed).
@ -1283,7 +1285,7 @@ export interface Page {
* await page.addInitScript(preloadFile);
* ```
*
* > **NOTE** The order of evaluation of multiple scripts installed via
* > NOTE: The order of evaluation of multiple scripts installed via
* [browserContext.addInitScript()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextaddinitscript)
* and [page.addInitScript()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageaddinitscript) is not
* defined.
@ -1486,9 +1488,8 @@ export interface Page {
*
* 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')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageondialog) event.
* > NOTE: if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned and should be handled manually
* via [page.on('dialog')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageondialog) event.
* @param options
*/
close(options?: {
@ -1529,7 +1530,7 @@ export interface Page {
* 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.
* > NOTE: `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
*
* Shortcut for main frame's
* [frame.dblclick()](https://github.com/microsoft/playwright/blob/master/docs/api.md#framedblclick).
@ -1688,7 +1689,9 @@ export interface Page {
* [browserContext.exposeFunction()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextexposefunction)
* for context-wide exposed function.
*
* > **NOTE** Functions installed via `page.exposeFunction` survive navigations.
* > NOTE: Functions installed via
* [page.exposeFunction()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageexposefunction) survive
* navigations.
*
* An example of adding an `md5` function to the page:
*
@ -1916,9 +1919,9 @@ export interface Page {
* Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
* [response.status()](https://github.com/microsoft/playwright/blob/master/docs/api.md#responsestatus).
*
* > **NOTE** `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
* > 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
* > 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()](https://github.com/microsoft/playwright/blob/master/docs/api.md#framegoto)
@ -2151,13 +2154,13 @@ export interface Page {
/**
* Returns the PDF buffer.
*
* > **NOTE** Generating a pdf is currently only supported in Chromium headless.
* > 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()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageemulatemedia) before calling
* `page.pdf()`:
*
* > **NOTE** By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
* > 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.
*
@ -2193,9 +2196,8 @@ export interface Page {
* - `A5`: 5.83in x 8.27in
* - `A6`: 4.13in x 5.83in
*
* > **NOTE** `headerTemplate` and `footerTemplate` markup have the following limitations:
* > 1. Script tags inside templates are not evaluated.
* > 2. Page styles are not visible inside templates.
* > NOTE: `headerTemplate` and `footerTemplate` markup have the following limitations: > 1. Script tags inside templates
* are not evaluated. > 2. Page styles are not visible inside templates.
* @param options
*/
pdf(options?: {
@ -2385,7 +2387,7 @@ export interface Page {
*
* Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
*
* > **NOTE** The handler will only be called for the first url if the response is a redirect.
* > NOTE: The handler will only be called for the first url if the response is a redirect.
*
* An example of a naïve handler that aborts all image requests:
*
@ -2409,7 +2411,7 @@ export interface Page {
* [browserContext.route()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextroute)) when
* request matches both handlers.
*
* > **NOTE** Enabling routing disables http cache.
* > NOTE: Enabling routing disables http cache.
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
* @param handler handler function to route the request.
*/
@ -2418,7 +2420,7 @@ export interface Page {
/**
* Returns the buffer with the captured screenshot.
*
* > **NOTE** Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for
* > NOTE: Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for
* discussion.
* @param options
*/
@ -2594,7 +2596,7 @@ export interface Page {
* - [page.setContent()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetcontent)
* - [page.waitForNavigation()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitfornavigation)
*
* > **NOTE**
* > NOTE:
* [page.setDefaultNavigationTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaultnavigationtimeout)
* takes priority over
* [page.setDefaultTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaulttimeout),
@ -2608,7 +2610,7 @@ export interface Page {
/**
* This setting will change the default maximum time for all the methods accepting `timeout` option.
*
* > **NOTE**
* > NOTE:
* [page.setDefaultNavigationTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaultnavigationtimeout)
* takes priority over
* [page.setDefaultTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaulttimeout).
@ -2619,7 +2621,9 @@ export interface Page {
/**
* The extra HTTP headers will be sent with every request the page initiates.
*
* > **NOTE** page.setExtraHTTPHeaders does not guarantee the order of headers in the outgoing requests.
* > NOTE:
* [page.setExtraHTTPHeaders()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetextrahttpheaders)
* does not guarantee the order of headers in the outgoing requests.
* @param headers An object containing additional HTTP headers to be sent with every request. All header values must be strings.
*/
setExtraHTTPHeaders(headers: { [key: string]: string; }): Promise<void>;
@ -2726,7 +2730,8 @@ export interface Page {
* 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.
* > NOTE: [page.tap()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagetap) requires that the
* `hasTouch` option of the browser context be set to true.
*
* Shortcut for main frame's [frame.tap()](https://github.com/microsoft/playwright/blob/master/docs/api.md#frametap).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://github.com/microsoft/playwright/blob/master/docs/selectors.md#working-with-selectors) for more details.
@ -2984,9 +2989,9 @@ export interface Page {
* Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
* [Download] instance.
*
* > **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
* download is not performed and user has no access to the downloaded files.
* > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
* performed and user has no access to the downloaded files.
*/
waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean, timeout?: number } | ((download: Download) => boolean)): Promise<Download>;
@ -3047,7 +3052,7 @@ export interface Page {
* console.log(await popup.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -3063,8 +3068,8 @@ export interface Page {
/**
* 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
* > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
* complete with
* [page.on('requestfinished')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfinished)
* event and not with
* [page.on('requestfailed')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfailed).
@ -3152,7 +3157,7 @@ export interface Page {
* ]);
* ```
*
* **NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
* > 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
@ -3255,7 +3260,7 @@ export interface Page {
* This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
* associated with the page.
*
* > **NOTE** This does not contain ServiceWorkers
* > NOTE: This does not contain ServiceWorkers
*/
workers(): Array<Worker>;}
@ -3699,7 +3704,7 @@ export interface Frame {
* When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
* Passing zero timeout disables this.
*
* > **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
* > NOTE: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://github.com/microsoft/playwright/blob/master/docs/selectors.md#working-with-selectors) for more details.
* @param options
*/
@ -3894,9 +3899,9 @@ export interface Frame {
* "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
* [response.status()](https://github.com/microsoft/playwright/blob/master/docs/api.md#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
* > 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).
* @param url URL to navigate frame to. The url should include scheme, e.g. `https://`.
* @param options
@ -4113,8 +4118,7 @@ export interface Frame {
*
* If the name is empty, returns the id attribute instead.
*
* > **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed
* later.
* > NOTE: This value is calculated once when the frame is created, and will not update if the attribute is changed later.
*/
name(): string;
@ -4338,7 +4342,7 @@ export interface Frame {
* When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
* Passing zero timeout disables this.
*
* > **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
* > NOTE: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://github.com/microsoft/playwright/blob/master/docs/selectors.md#working-with-selectors) for more details.
* @param options
*/
@ -4533,7 +4537,7 @@ export interface Frame {
* ]);
* ```
*
* **NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
* > 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.
* @param options
*/
@ -4677,7 +4681,7 @@ export interface BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -4710,7 +4714,7 @@ export interface BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -4743,7 +4747,7 @@ export interface BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -4776,7 +4780,7 @@ export interface BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -4809,7 +4813,7 @@ export interface BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -4890,7 +4894,7 @@ export interface BrowserContext {
* });
* ```
*
* > **NOTE** The order of evaluation of multiple scripts installed via
* > NOTE: The order of evaluation of multiple scripts installed via
* [browserContext.addInitScript()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextaddinitscript)
* and [page.addInitScript()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageaddinitscript) is not
* defined.
@ -4936,7 +4940,7 @@ export interface BrowserContext {
/**
* Closes the browser context. All the pages that belong to the browser context will be closed.
*
* > **NOTE** the default browser context cannot be closed.
* > NOTE: The default browser context cannot be closed.
*/
close(): Promise<void>;
@ -5052,7 +5056,7 @@ export interface BrowserContext {
* Page routes (set up with [page.route()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageroute))
* take precedence over browser context routes when request matches both handlers.
*
* > **NOTE** Enabling routing disables http cache.
* > NOTE: Enabling routing disables http cache.
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
* @param handler handler function to route the request.
*/
@ -5067,7 +5071,7 @@ export interface BrowserContext {
* - [page.setContent()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetcontent)
* - [page.waitForNavigation()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitfornavigation)
*
* > **NOTE**
* > NOTE:
* [page.setDefaultNavigationTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaultnavigationtimeout)
* and [page.setDefaultTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaulttimeout)
* take priority over
@ -5079,7 +5083,7 @@ export interface BrowserContext {
/**
* This setting will change the default maximum time for all the methods accepting `timeout` option.
*
* > **NOTE**
* > NOTE:
* [page.setDefaultNavigationTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaultnavigationtimeout),
* [page.setDefaultTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetdefaulttimeout) and
* [browserContext.setDefaultNavigationTimeout()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextsetdefaultnavigationtimeout)
@ -5096,7 +5100,9 @@ export interface BrowserContext {
* 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.
* > NOTE:
* [browserContext.setExtraHTTPHeaders()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextsetextrahttpheaders)
* does not guarantee the order of headers in the outgoing requests.
* @param headers An object containing additional HTTP headers to be sent with every request. All header values must be strings.
*/
setExtraHTTPHeaders(headers: { [key: string]: string; }): Promise<void>;
@ -5108,7 +5114,7 @@ export interface BrowserContext {
* await browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});
* ```
*
* > **NOTE** Consider using
* > NOTE: Consider using
* [browserContext.grantPermissions()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextgrantpermissions)
* to grant permissions for the browser context pages to read its geolocation.
* @param geolocation
@ -5226,7 +5232,7 @@ export interface BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -5368,7 +5374,7 @@ export interface JSHandle<T = any> {
/**
* Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
*
* > **NOTE** The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
* > NOTE: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
* error if the object has circular references.
*/
jsonValue(): Promise<T>;
@ -5521,7 +5527,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* const span = await div.waitForSelector('span', { state: 'attached' });
* ```
*
* > **NOTE** This method does not work across navigations, use
* > NOTE: This method does not work across navigations, use
* [page.waitForSelector()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforselector) instead.
* @param selector A selector to query for. See [working with selectors](https://github.com/microsoft/playwright/blob/master/docs/selectors.md#working-with-selectors) for more details.
* @param options
@ -5699,7 +5705,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
* Passing zero timeout disables this.
*
* > **NOTE** `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
* > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
* @param options
*/
dblclick(options?: {
@ -6178,7 +6184,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* When all steps combined have not finished during the specified `timeout`, this method rejects with a [TimeoutError].
* Passing zero timeout disables this.
*
* > **NOTE** `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
* > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
* @param options
*/
tap(options?: {
@ -6864,7 +6870,7 @@ export interface BrowserType<Browser> {
*
* [ChromiumBrowser] can also be used for testing Chrome Extensions.
*
* > **NOTE** Extensions in Chrome / Chromium currently only work in non-headless mode.
* > NOTE: Extensions in Chrome / Chromium currently only work in non-headless mode.
*
* The following is code for getting a handle to the
* [background page](https://developer.chrome.com/extensions/background_pages) of an extension whose source is located in
@ -7040,7 +7046,7 @@ export interface Accessibility {
* Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
* page.
*
* > **NOTE** The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
* > NOTE: The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
* Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
*
* An example of dumping the entire accessibility tree:
@ -7137,9 +7143,6 @@ export {};
* })();
* ```
*
* See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific features. Note that
* [browserType.launch()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsertypelaunch) always
* returns a specific browser instance, based on the browser being launched.
*/
export interface Browser extends EventEmitter {
/**
@ -7601,7 +7604,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
/**
* Emitted when new background page is created in the context.
*
* > **NOTE** Only works with persistent context.
* > NOTE: Only works with persistent context.
*/
on(event: 'backgroundpage', listener: (page: Page) => void): this;
@ -7637,7 +7640,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -7646,7 +7649,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
/**
* Emitted when new background page is created in the context.
*
* > **NOTE** Only works with persistent context.
* > NOTE: Only works with persistent context.
*/
once(event: 'backgroundpage', listener: (page: Page) => void): this;
@ -7682,7 +7685,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -7691,7 +7694,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
/**
* Emitted when new background page is created in the context.
*
* > **NOTE** Only works with persistent context.
* > NOTE: Only works with persistent context.
*/
addListener(event: 'backgroundpage', listener: (page: Page) => void): this;
@ -7727,7 +7730,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -7736,7 +7739,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
/**
* Emitted when new background page is created in the context.
*
* > **NOTE** Only works with persistent context.
* > NOTE: Only works with persistent context.
*/
removeListener(event: 'backgroundpage', listener: (page: Page) => void): this;
@ -7772,7 +7775,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -7781,7 +7784,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
/**
* Emitted when new background page is created in the context.
*
* > **NOTE** Only works with persistent context.
* > NOTE: Only works with persistent context.
*/
off(event: 'backgroundpage', listener: (page: Page) => void): this;
@ -7817,7 +7820,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -7842,7 +7845,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
/**
* Emitted when new background page is created in the context.
*
* > **NOTE** Only works with persistent context.
* > NOTE: Only works with persistent context.
*/
waitForEvent(event: 'backgroundpage', optionsOrPredicate?: { predicate?: (page: Page) => boolean, timeout?: number } | ((page: Page) => boolean)): Promise<Page>;
@ -7878,7 +7881,7 @@ export interface ChromiumBrowserContext extends BrowserContext {
* console.log(await page.evaluate('location.href'));
* ```
*
* > **NOTE** Use
* > NOTE: Use
* [page.waitForLoadState()](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstate) to wait
* until the page gets to a particular state (you should not need it in most cases).
*/
@ -7927,8 +7930,8 @@ export interface ChromiumCoverage {
/**
* Returns coverage is started
*
* > **NOTE** Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created
* on the page using `eval` or `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous scripts will have
* > NOTE: Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created on
* the page using `eval` or `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous scripts will have
* `__playwright_evaluation_script__` as their URL.
* @param options
*/
@ -7947,7 +7950,7 @@ export interface ChromiumCoverage {
/**
* Returns the array of coverage reports for all stylesheets
*
* > **NOTE** CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
* > NOTE: CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
*/
stopCSSCoverage(): Promise<Array<{
/**
@ -7979,8 +7982,7 @@ export interface ChromiumCoverage {
/**
* Returns the array of coverage reports for all scripts
*
* > **NOTE** JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are
* reported.
* > NOTE: JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are reported.
*/
stopJSCoverage(): Promise<Array<{
/**
@ -8120,9 +8122,9 @@ export interface Dialog {
* ...
* ```
*
* > **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual
* download is not performed and user has no access to the downloaded files.
* > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
* downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
* performed and user has no access to the downloaded files.
*/
export interface Download {
/**
@ -8327,7 +8329,7 @@ export interface Keyboard {
* [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
* [keyboard.up()](https://github.com/microsoft/playwright/blob/master/docs/api.md#keyboardup).
*
* > **NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
* > NOTE: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
*/
down(key: string): Promise<void>;
@ -8339,7 +8341,7 @@ export interface Keyboard {
* page.keyboard.insertText('嗨');
* ```
*
* > **NOTE** Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
* > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
* @param text Sets input to the specified text value.
*/
insertText(text: string): Promise<void>;
@ -8397,7 +8399,7 @@ export interface Keyboard {
* await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
* ```
*
* > **NOTE** Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
* > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
* @param text A text to type into a focused element.
* @param options
*/
@ -8581,8 +8583,8 @@ export interface Mouse {
* the [page.on('requestfailed')](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageonrequestfailed)
* event is emitted.
*
* > **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request
* will complete with `'requestfinished'` event.
* > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
* complete with `'requestfinished'` event.
*
* If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
* request is issued to a redirected url.

View File

@ -625,6 +625,10 @@ function generateSourceCodeComment(spec) {
md.visitAll(comments, node => {
if (node.liType === 'bullet')
node.liType = 'default';
if (node.type === 'note') {
node.type = 'text';
node.text = '> NOTE: ' + node.text;
}
});
return md.render(comments, 120);
}

View File

@ -17,9 +17,10 @@
// @ts-check
/** @typedef {{
* type: 'text' | 'li' | 'code' | 'properties' | 'h0' | 'h1' | 'h2' | 'h3' | 'h4',
* type: 'text' | 'li' | 'code' | 'properties' | 'h0' | 'h1' | 'h2' | 'h3' | 'h4' | 'note',
* text?: string,
* codeLang?: string,
* noteType?: string,
* lines?: string[],
* liType?: 'default' | 'bullet' | 'ordinal',
* children?: MarkdownNode[]
@ -42,7 +43,7 @@ function flattenWrappedLines(content) {
|| trimmedLine.startsWith('*')
|| line.match(/\[[^\]]+\]:.*/)
|| singleLineExpression;
if (trimmedLine.startsWith('```') || trimmedLine.startsWith('---')) {
if (trimmedLine.startsWith('```') || trimmedLine.startsWith('---') || trimmedLine.startsWith(':::')) {
inCodeBlock = !inCodeBlock;
flushLastParagraph = true;
}
@ -137,6 +138,29 @@ function buildTree(lines) {
continue;
}
if (content.startsWith(':::')) {
/** @type {MarkdownNode} */
const node = {
type: 'note',
noteType: content.substring(3)
};
line = lines[++i];
const tokens = [];
while (!line.trim().startsWith(':::')) {
if (!line.startsWith(indent)) {
const from = Math.max(0, i - 5)
const to = Math.min(lines.length, from + 10);
const snippet = lines.slice(from, to);
throw new Error(`Bad comment block: ${snippet.join('\n')}`);
}
tokens.push(line.substring(indent.length));
line = lines[++i];
}
node.text = tokens.join(' ');
appendNode(indent, node);
continue;
}
if (content.startsWith('---')) {
/** @type {MarkdownNode} */
const node = {
@ -237,6 +261,15 @@ function innerRenderMdNode(indent, node, lastNode, result, maxColumns) {
return;
}
if (node.type === 'note') {
newLine();
result.push(`${indent}:::${node.noteType}`);
result.push(`${wrapText(node.text, maxColumns, indent)}`);
result.push(`${indent}:::`);
newLine();
return;
}
if (node.type === 'properties') {
result.push(`${indent}---`);
for (const line of node.lines)