docs: use "argument: <type>" notation for events (#5626)
This commit is contained in:
parent
cb0a890a09
commit
96e099aca3
|
|
@ -4,7 +4,7 @@
|
|||
[AndroidDevice] represents a connected device, either real hardware or emulated. Devices can be obtained using [`method: Android.devices`].
|
||||
|
||||
## event: AndroidDevice.webView
|
||||
- type: <[AndroidWebView]>
|
||||
- argument: <[AndroidWebView]>
|
||||
|
||||
Emitted when a new WebView instance is detected.
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
Emitted when the socket is closed.
|
||||
|
||||
## event: AndroidSocket.data
|
||||
- type: <[Buffer]>
|
||||
- argument: <[Buffer]>
|
||||
|
||||
Emitted when data is available to read from the socket.
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ with sync_playwright() as playwright:
|
|||
```
|
||||
|
||||
## event: Browser.disconnected
|
||||
- type: <[Browser]>
|
||||
- argument: <[Browser]>
|
||||
|
||||
Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
|
||||
* Browser application is closed or crashed.
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ context.close()
|
|||
```
|
||||
|
||||
## event: BrowserContext.close
|
||||
- type: <[BrowserContext]>
|
||||
- argument: <[BrowserContext]>
|
||||
|
||||
Emitted when Browser context gets closed. This might happen because of one of the following:
|
||||
* Browser context is closed.
|
||||
|
|
@ -58,7 +58,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
|
||||
- type: <[Page]>
|
||||
- argument: <[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.
|
||||
|
|
@ -636,7 +636,7 @@ Creates a new page in the browser context.
|
|||
## method: BrowserContext.pages
|
||||
- returns: <[Array]<[Page]>>
|
||||
|
||||
Returns all open pages in the context.
|
||||
Returns all open pages in the context.
|
||||
|
||||
## async method: BrowserContext.route
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ background_page = context.wait_for_event("backgroundpage")
|
|||
```
|
||||
|
||||
## event: ChromiumBrowserContext.backgroundPage
|
||||
- type: <[Page]>
|
||||
- argument: <[Page]>
|
||||
|
||||
Emitted when new background page is created in the context.
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ Only works with persistent context.
|
|||
:::
|
||||
|
||||
## event: ChromiumBrowserContext.serviceWorker
|
||||
- type: <[Worker]>
|
||||
- argument: <[Worker]>
|
||||
|
||||
Emitted when new service worker is created in the context.
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const { _electron: electron } = require('playwright');
|
|||
This event is issued when the application closes.
|
||||
|
||||
## event: ElectronApplication.window
|
||||
- type: <[Page]>
|
||||
- argument: <[Page]>
|
||||
|
||||
This event is issued for every window that is created **and loaded** in Electron. It contains a [Page] that can
|
||||
be used for Playwright automation.
|
||||
|
|
@ -48,7 +48,7 @@ be used for Playwright automation.
|
|||
Closes Electron application.
|
||||
|
||||
## method: ElectronApplication.context
|
||||
- type: <[BrowserContext]>
|
||||
- returns: <[BrowserContext]>
|
||||
|
||||
This method returns browser context that can be used for setting up context-wide routing, etc.
|
||||
|
||||
|
|
|
|||
|
|
@ -120,12 +120,12 @@ page.remove_listener("request", log_request)
|
|||
```
|
||||
|
||||
## event: Page.close
|
||||
- type: <[Page]>
|
||||
- argument: <[Page]>
|
||||
|
||||
Emitted when the page closes.
|
||||
|
||||
## event: Page.console
|
||||
- type: <[ConsoleMessage]>
|
||||
- argument: <[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.
|
||||
|
|
@ -169,7 +169,7 @@ page.evaluate("console.log('hello', 5, {foo: 'bar'})")
|
|||
```
|
||||
|
||||
## event: Page.crash
|
||||
- type: <[Page]>
|
||||
- argument: <[Page]>
|
||||
|
||||
Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes,
|
||||
ongoing and subsequent operations will throw.
|
||||
|
|
@ -219,7 +219,7 @@ except Error as e:
|
|||
```
|
||||
|
||||
## event: Page.dialog
|
||||
- type: <[Dialog]>
|
||||
- argument: <[Dialog]>
|
||||
|
||||
Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise the page will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and actions like click will never finish.
|
||||
|
||||
|
|
@ -228,13 +228,13 @@ When no [`event: Page.dialog`] listeners are present, all dialogs are automatica
|
|||
:::
|
||||
|
||||
## event: Page.DOMContentLoaded
|
||||
- type: <[Page]>
|
||||
- argument: <[Page]>
|
||||
|
||||
Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded)
|
||||
event is dispatched.
|
||||
|
||||
## event: Page.download
|
||||
- type: <[Download]>
|
||||
- argument: <[Download]>
|
||||
|
||||
Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
|
||||
[Download] instance.
|
||||
|
|
@ -246,7 +246,7 @@ not performed and user has no access to the downloaded files.
|
|||
:::
|
||||
|
||||
## event: Page.fileChooser
|
||||
- type: <[FileChooser]>
|
||||
- argument: <[FileChooser]>
|
||||
|
||||
Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can
|
||||
respond to it via setting the input files using [`method: FileChooser.setFiles`] that can be uploaded after that.
|
||||
|
|
@ -268,36 +268,36 @@ page.on("filechooser", lambda file_chooser: file_chooser.set_files("/tmp/myfile.
|
|||
```
|
||||
|
||||
## event: Page.frameAttached
|
||||
- type: <[Frame]>
|
||||
- argument: <[Frame]>
|
||||
|
||||
Emitted when a frame is attached.
|
||||
|
||||
## event: Page.frameDetached
|
||||
- type: <[Frame]>
|
||||
- argument: <[Frame]>
|
||||
|
||||
Emitted when a frame is detached.
|
||||
|
||||
## event: Page.frameNavigated
|
||||
- type: <[Frame]>
|
||||
- argument: <[Frame]>
|
||||
|
||||
Emitted when a frame is navigated to a new url.
|
||||
|
||||
## event: Page.load
|
||||
- type: <[Page]>
|
||||
- argument: <[Page]>
|
||||
|
||||
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.
|
||||
|
||||
## event: Page.pageError
|
||||
- type: <[Error]>
|
||||
- argument: <[Error]>
|
||||
|
||||
Emitted when an uncaught exception happens within the page.
|
||||
|
||||
## event: Page.pageError
|
||||
* langs: csharp, java
|
||||
- type: <[string]>
|
||||
- argument: <[string]>
|
||||
|
||||
## event: Page.popup
|
||||
- type: <[Page]>
|
||||
- argument: <[Page]>
|
||||
|
||||
Emitted when the page opens a new tab or window. This event is emitted in addition to the
|
||||
[`event: BrowserContext.page`], but only for popups relevant to this page.
|
||||
|
|
@ -341,13 +341,13 @@ cases).
|
|||
:::
|
||||
|
||||
## event: Page.request
|
||||
- type: <[Request]>
|
||||
- argument: <[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
|
||||
- type: <[Request]>
|
||||
- argument: <[Request]>
|
||||
|
||||
Emitted when a request fails, for example by timing out.
|
||||
|
||||
|
|
@ -357,24 +357,24 @@ with [`event: Page.requestFinished`] event and not with [`event: Page.requestFai
|
|||
:::
|
||||
|
||||
## event: Page.requestFinished
|
||||
- type: <[Request]>
|
||||
- argument: <[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
|
||||
- type: <[Response]>
|
||||
- argument: <[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
|
||||
- type: <[WebSocket]>
|
||||
- argument: <[WebSocket]>
|
||||
|
||||
Emitted when [WebSocket] request is sent.
|
||||
|
||||
## event: Page.worker
|
||||
- type: <[Worker]>
|
||||
- argument: <[Worker]>
|
||||
|
||||
Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the
|
||||
page.
|
||||
|
|
|
|||
|
|
@ -3,32 +3,32 @@
|
|||
The [WebSocket] class represents websocket connections in the page.
|
||||
|
||||
## event: WebSocket.close
|
||||
- type: <[WebSocket]>
|
||||
- argument: <[WebSocket]>
|
||||
|
||||
Fired when the websocket closes.
|
||||
|
||||
## event: WebSocket.frameReceived
|
||||
- type: <[Object]>
|
||||
- argument: <[Object]>
|
||||
- `payload` <[string]|[Buffer]> frame payload
|
||||
|
||||
Fired when the websocket recieves a frame.
|
||||
|
||||
## event: WebSocket.frameReceived
|
||||
* langs: csharp, java
|
||||
- type: <[WebSocketFrame]>
|
||||
- argument: <[WebSocketFrame]>
|
||||
|
||||
## event: WebSocket.frameSent
|
||||
- type: <[Object]>
|
||||
- argument: <[Object]>
|
||||
- `payload` <[string]|[Buffer]> frame payload
|
||||
|
||||
Fired when the websocket sends a frame.
|
||||
|
||||
## event: WebSocket.frameSent
|
||||
* langs: csharp, java
|
||||
- type: <[WebSocketFrame]>
|
||||
- argument: <[WebSocketFrame]>
|
||||
|
||||
## event: WebSocket.socketError
|
||||
- type: <[String]>
|
||||
- argument: <[String]>
|
||||
|
||||
Fired when the websocket has an error.
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ for worker in page.workers:
|
|||
```
|
||||
|
||||
## event: Worker.close
|
||||
- type: <[Worker]>
|
||||
- argument: <[Worker]>
|
||||
|
||||
Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is terminated.
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ Returns the return value of [`param: expression`].
|
|||
If the function passed to the [`method: Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate`] would wait for the promise
|
||||
to resolve and return its value.
|
||||
|
||||
If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some
|
||||
If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some
|
||||
additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
||||
|
||||
### param: Worker.evaluate.expression = %%-evaluate-expression-%%
|
||||
|
|
@ -66,7 +66,7 @@ Optional argument to pass to [`param: expression`].
|
|||
Returns the return value of [`param: expression`] as a [JSHandle].
|
||||
|
||||
The only difference between [`method: Worker.evaluate`] and
|
||||
[`method: Worker.evaluateHandle`] is that [`method: Worker.evaluateHandle`]
|
||||
[`method: Worker.evaluateHandle`] is that [`method: Worker.evaluateHandle`]
|
||||
returns [JSHandle].
|
||||
|
||||
If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then [`method: Worker.evaluateHandle`] would wait for
|
||||
|
|
|
|||
4
types/types.d.ts
vendored
4
types/types.d.ts
vendored
|
|
@ -4917,7 +4917,7 @@ export interface BrowserContext {
|
|||
newPage(): Promise<Page>;
|
||||
|
||||
/**
|
||||
* Returns all open pages in the context.
|
||||
* Returns all open pages in the context.
|
||||
*/
|
||||
pages(): Array<Page>;
|
||||
|
||||
|
|
@ -5158,7 +5158,7 @@ export interface Worker {
|
|||
* [worker.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-worker#workerevaluatepagefunction-arg)
|
||||
* returns a non-[Serializable] value, then
|
||||
* [worker.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-worker#workerevaluatepagefunction-arg)
|
||||
* returns `undefined`. Playwright also supports transferring some additional values that are not serializable by `JSON`:
|
||||
* returns `undefined`. Playwright also supports transferring some additional values that are not serializable by `JSON`:
|
||||
* `-0`, `NaN`, `Infinity`, `-Infinity`.
|
||||
* @param pageFunction Function to be evaluated in the worker context.
|
||||
* @param arg Optional argument to pass to `pageFunction`.
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ class ApiParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string} line
|
||||
* @param {string} line
|
||||
* @returns {{ name: string, type: string, text: string }}
|
||||
*/
|
||||
function parseVariable(line) {
|
||||
|
|
@ -194,6 +194,8 @@ function parseVariable(line) {
|
|||
match = line.match(/^(returns): (.*)/);
|
||||
if (!match)
|
||||
match = line.match(/^(type): (.*)/);
|
||||
if (!match)
|
||||
match = line.match(/^(argument): (.*)/);
|
||||
if (!match)
|
||||
throw new Error('Invalid argument: ' + line);
|
||||
const name = match[1];
|
||||
|
|
|
|||
Loading…
Reference in a new issue