Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs: use "argument: <type>" notation for events (#5626)
Dmitry Gozman96e099aca32f
diff --git a/docs/src/api/class-androiddevice.md b/docs/src/api/class-androiddevice.mdindex 50c2db9355..3f4b2896a7 100644--- a/docs/src/api/class-androiddevice.md+++ b/docs/src/api/class-androiddevice.md@@ -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.diff --git a/docs/src/api/class-androidsocket.md b/docs/src/api/class-androidsocket.mdindex b63e760eda..b55354423b 100644--- a/docs/src/api/class-androidsocket.md+++ b/docs/src/api/class-androidsocket.md@@ -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.diff --git a/docs/src/api/class-browser.md b/docs/src/api/class-browser.mdindex b58a831a9c..5a36590f3e 100644--- a/docs/src/api/class-browser.md+++ b/docs/src/api/class-browser.md@@ -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.diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.mdindex 8bb6a049b5..271de36735 100644--- a/docs/src/api/class-browsercontext.md+++ b/docs/src/api/class-browsercontext.md@@ -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 willalso 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.routediff --git a/docs/src/api/class-chromiumbrowsercontext.md b/docs/src/api/class-chromiumbrowsercontext.mdindex 4d02944880..0ee89ed8c0 100644--- a/docs/src/api/class-chromiumbrowsercontext.md+++ b/docs/src/api/class-chromiumbrowsercontext.md@@ -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.diff --git a/docs/src/api/class-electronapplication.md b/docs/src/api/class-electronapplication.mdindex 77af88ff46..0b0fd3914c 100644--- a/docs/src/api/class-electronapplication.md+++ b/docs/src/api/class-electronapplication.md@@ -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 canbe 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.diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.mdindex e553fc94dc..9978dd333b 100644--- a/docs/src/api/class-page.md+++ b/docs/src/api/class-page.md@@ -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`. Alsoemitted 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 canrespond 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, thesequence 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 eventsis `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 thepage.diff --git a/docs/src/api/class-websocket.md b/docs/src/api/class-websocket.mdindex 7db9ffa0dc..626335f914 100644--- a/docs/src/api/class-websocket.md+++ b/docs/src/api/class-websocket.md@@ -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 payloadFired 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 payloadFired 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.diff --git a/docs/src/api/class-worker.md b/docs/src/api/class-worker.mdindex 04bf4fbb86..79cd4fa2bd 100644--- a/docs/src/api/class-worker.md+++ b/docs/src/api/class-worker.md@@ -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 promiseto 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 someadditional 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 fordiff --git a/types/types.d.ts b/types/types.d.tsindex 4b2df6a3c8..95459d902d 100644--- a/types/types.d.ts+++ b/types/types.d.ts@@ -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`.diff --git a/utils/doclint/api_parser.js b/utils/doclint/api_parser.jsindex ba375542c2..4cbf6f4ea0 100644--- a/utils/doclint/api_parser.js+++ b/utils/doclint/api_parser.js@@ -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];