diff --git a/types/types.d.ts b/types/types.d.ts index 00c779e335..a163f77043 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -30,7 +30,9 @@ type ElementHandleWaitForSelectorOptionsNotHidden = ElementHandleWaitForSelector /** * - extends: [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) * - * Page provides methods to interact with a single tab in a [Browser], or an [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [Browser] instance might have multiple [Page] instances. + * Page provides methods to interact with a single tab in a [Browser], or an + * [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [Browser] + * instance might have multiple [Page] instances. * * This example creates a page, navigates it to a URL, and then saves a screenshot: * @@ -47,7 +49,9 @@ type ElementHandleWaitForSelectorOptionsNotHidden = ElementHandleWaitForSelector * })(); * ``` * - * The Page class emits various events (described below) which can be handled using any of Node's native [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or `removeListener`. + * The Page class emits various events (described below) which can be handled using any of Node's native + * [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or + * `removeListener`. * * This example logs a message for a single page `load` event: * @@ -71,9 +75,12 @@ export interface Page { /** * Returns the value of the `pageFunction` invocation. * - * If the function passed to the `page.evaluate` returns a [Promise], then `page.evaluate` would wait for the promise to resolve and return its value. + * If the function passed to the `page.evaluate` returns a [Promise], then `page.evaluate` would wait for the promise to + * resolve and return its value. * - * If the function passed to the `page.evaluate` returns a non-[Serializable] value, then `page.evaluate` resolves to `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals. + * If the function passed to the `page.evaluate` returns a non-[Serializable] value, then `page.evaluate` resolves to + * `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`: + * `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals. * * Passing argument to `pageFunction`: * @@ -100,7 +107,8 @@ export interface Page { * await bodyHandle.dispose(); * ``` * - * Shortcut for main frame's [`frame.evaluate(pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameevaluatepagefunction-arg). + * Shortcut for main frame's + * [`frame.evaluate(pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameevaluatepagefunction-arg). * @param pageFunction Function to be evaluated in the page context * @param arg Optional argument to pass to `pageFunction` */ @@ -110,9 +118,11 @@ export interface Page { /** * Returns the value of the `pageFunction` invocation as in-page object (JSHandle). * - * The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page object (JSHandle). + * The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page + * object (JSHandle). * - * If the function passed to the `page.evaluateHandle` returns a [Promise], then `page.evaluateHandle` would wait for the promise to resolve and return its value. + * If the function passed to the `page.evaluateHandle` returns a [Promise], then `page.evaluateHandle` would wait for the + * promise to resolve and return its value. * * A string can also be passed in instead of a function: * @@ -136,27 +146,34 @@ export interface Page { evaluateHandle(pageFunction: PageFunction, arg?: any): Promise>; /** - * The method finds an element matching the specified selector within the page. If no elements match the selector, the return value resolves to `null`. + * The method finds an element matching the specified selector within the page. If no elements match the selector, the + * return value resolves to `null`. * - * Shortcut for main frame's [`frame.$(selector)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameselector). + * Shortcut for main frame's + * [`frame.$(selector)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameselector). * @param selector A selector to query for. See [working with selectors](https://github.com/microsoft/playwright/blob/master/docs/api.md#working-with-selectors) for more details. */ $(selector: K): Promise | null>; $(selector: string): Promise | null>; /** - * The method finds all elements matching the specified selector within the page. If no elements match the selector, the return value resolves to `[]`. + * The method finds all elements matching the specified selector within the page. If no elements match the selector, the + * return value resolves to `[]`. * - * Shortcut for main frame's [`frame.$$(selector)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameselector). + * Shortcut for main frame's + * [`frame.$$(selector)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameselector). * @param selector A selector to query for. See [working with selectors](https://github.com/microsoft/playwright/blob/master/docs/api.md#working-with-selectors) for more details. */ $$(selector: K): Promise[]>; $$(selector: string): Promise[]>; /** - * The method finds an element matching the specified selector within the page and passes it as a first argument to `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`. + * The method finds an element matching the specified selector within the page and passes it as a first argument to + * `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`. * - * If `pageFunction` returns a [Promise], then [`page.$eval(selector, pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageevalselector-pagefunction-arg) would wait for the promise to resolve and return its value. + * If `pageFunction` returns a [Promise], then + * [`page.$eval(selector, pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageevalselector-pagefunction-arg) + * would wait for the promise to resolve and return its value. * * Examples: * @@ -166,7 +183,8 @@ export interface Page { * const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello'); * ``` * - * Shortcut for main frame's [`frame.$eval(selector, pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameevalselector-pagefunction-arg). + * Shortcut for main frame's + * [`frame.$eval(selector, pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#frameevalselector-pagefunction-arg). * @param selector A selector to query for. See [working with selectors](https://github.com/microsoft/playwright/blob/master/docs/api.md#working-with-selectors) for more details. * @param pageFunction Function to be evaluated in browser context * @param arg Optional argument to pass to `pageFunction` @@ -177,9 +195,12 @@ export interface Page { $eval(selector: string, pageFunction: PageFunctionOn, arg?: any): Promise; /** - * The method finds all elements matching the specified selector within the page and passes an array of matched elements as a first argument to `pageFunction`. Returns the result of `pageFunction` invocation. + * The method finds all elements matching the specified selector within the page and passes an array of matched elements as + * a first argument to `pageFunction`. Returns the result of `pageFunction` invocation. * - * If `pageFunction` returns a [Promise], then [`page.$$eval(selector, pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageevalselector-pagefunction-arg) would wait for the promise to resolve and return its value. + * If `pageFunction` returns a [Promise], then + * [`page.$$eval(selector, pageFunction[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageevalselector-pagefunction-arg) + * would wait for the promise to resolve and return its value. * * Examples: * @@ -221,7 +242,8 @@ export interface Page { * await page.waitForFunction(selector => !!document.querySelector(selector), selector); * ``` * - * Shortcut for main frame's [`frame.waitForFunction(pageFunction[, arg, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#framewaitforfunctionpagefunction-arg-options). + * Shortcut for main frame's + * [`frame.waitForFunction(pageFunction[, arg, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#framewaitforfunctionpagefunction-arg-options). * @param pageFunction Function to be evaluated in browser context * @param arg Optional argument to pass to `pageFunction` * @param options @@ -230,9 +252,12 @@ export interface Page { waitForFunction(pageFunction: PageFunction, arg?: any, options?: PageWaitForFunctionOptions): Promise>; /** - * Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`. + * Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or + * `detached`. * - * Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw. + * Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at + * the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the + * selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw. * * This method works across navigations: * @@ -262,11 +287,16 @@ export interface Page { waitForSelector(selector: string, options: PageWaitForSelectorOptions): Promise>; /** - * The method adds a function called `name` on the `window` object of every frame in this page. When called, the function executes `playwrightBinding` and returns a [Promise] which resolves to the return value of `playwrightBinding`. If the `playwrightBinding` returns a [Promise], it will be awaited. + * The method adds a function called `name` on the `window` object of every frame in this page. When called, the function + * executes `playwrightBinding` and returns a [Promise] which resolves to the return value of `playwrightBinding`. If the + * `playwrightBinding` returns a [Promise], it will be awaited. * - * The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext: BrowserContext, page: Page, frame: Frame }`. + * The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext: + * BrowserContext, page: Page, frame: Frame }`. * - * See [`browserContext.exposeBinding(name, playwrightBinding[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextexposebindingname-playwrightbinding-options) for the context-wide version. + * See + * [`browserContext.exposeBinding(name, playwrightBinding[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextexposebindingname-playwrightbinding-options) + * for the context-wide version. * * > **NOTE** Functions installed via `page.exposeBinding` survive navigations. * @@ -320,7 +350,8 @@ export interface Page { on(event: 'close', listener: () => void): this; /** - * 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. + * 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. * * The arguments passed into `console.log` appear as arguments on the event handler. * @@ -338,7 +369,8 @@ export interface Page { on(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** - * 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. + * 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. * * The most common way to deal with crashes is to catch an exception: * @@ -353,7 +385,8 @@ export interface Page { * } * ``` * - * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, handling `crash` event helps: + * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, + * handling `crash` event helps: * * ```js * await new Promise((resolve, reject) => { @@ -369,24 +402,34 @@ export interface Page { on(event: 'crash', listener: () => void): this; /** - * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. + * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond + * to the dialog via + * [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) + * or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. */ on(event: 'dialog', listener: (dialog: Dialog) => void): this; /** - * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched. + * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) + * event is dispatched. */ on(event: 'domcontentloaded', listener: () => void): this; /** - * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance. + * 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 or set to `false`, 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; /** - * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can respond to it via setting the input files using [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) that can be uploaded after that. + * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can + * respond to it via setting the input files using + * [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) + * that can be uploaded after that. * * ```js * page.on('filechooser', async (fileChooser) => { @@ -423,9 +466,13 @@ export interface Page { on(event: 'pageerror', listener: (error: Error) => void): this; /** - * Emitted when the page opens a new tab or window. This event is emitted in addition to the [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but only for popups relevant to this page. + * Emitted when the page opens a new tab or window. This event is emitted in addition to the + * [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but + * only for popups relevant to this page. * - * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is done and its response has started loading in the popup. + * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a + * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is + * done and its response has started loading in the popup. * * ```js * const [popup] = await Promise.all([ @@ -435,29 +482,39 @@ export interface Page { * console.log(await popup.evaluate('location.href')); * ``` * - * > **NOTE** Use [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in most cases). + * > **NOTE** Use + * [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) + * to wait until the page gets to a particular state (you should not need it in most cases). */ on(event: 'popup', listener: (page: Page) => void): this; /** - * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). + * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see + * [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or + * [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). */ on(event: 'request', listener: (request: Request) => void): this; /** * Emitted when a request fails, for example by timing out. * - * > **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with [`page.on('requestfinished')`](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). + * > **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). */ on(event: 'requestfailed', listener: (request: Request) => void): this; /** - * Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when a request finishes successfully after downloading the response body. For a successful response, the + * sequence of events is `request`, `response` and `requestfinished`. */ on(event: 'requestfinished', listener: (request: Request) => void): this; /** - * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events + * is `request`, `response` and `requestfinished`. */ on(event: 'response', listener: (response: Response) => void): this; @@ -467,7 +524,8 @@ export interface Page { on(event: 'websocket', listener: (webSocket: WebSocket) => void): this; /** - * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page. + * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the + * page. */ on(event: 'worker', listener: (worker: Worker) => void): this; @@ -477,7 +535,8 @@ export interface Page { once(event: 'close', listener: () => void): this; /** - * 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. + * 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. * * The arguments passed into `console.log` appear as arguments on the event handler. * @@ -495,7 +554,8 @@ export interface Page { once(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** - * 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. + * 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. * * The most common way to deal with crashes is to catch an exception: * @@ -510,7 +570,8 @@ export interface Page { * } * ``` * - * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, handling `crash` event helps: + * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, + * handling `crash` event helps: * * ```js * await new Promise((resolve, reject) => { @@ -526,24 +587,34 @@ export interface Page { once(event: 'crash', listener: () => void): this; /** - * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. + * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond + * to the dialog via + * [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) + * or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. */ once(event: 'dialog', listener: (dialog: Dialog) => void): this; /** - * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched. + * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) + * event is dispatched. */ once(event: 'domcontentloaded', listener: () => void): this; /** - * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance. + * 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 or set to `false`, 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; /** - * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can respond to it via setting the input files using [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) that can be uploaded after that. + * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can + * respond to it via setting the input files using + * [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) + * that can be uploaded after that. * * ```js * page.on('filechooser', async (fileChooser) => { @@ -580,9 +651,13 @@ export interface Page { once(event: 'pageerror', listener: (error: Error) => void): this; /** - * Emitted when the page opens a new tab or window. This event is emitted in addition to the [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but only for popups relevant to this page. + * Emitted when the page opens a new tab or window. This event is emitted in addition to the + * [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but + * only for popups relevant to this page. * - * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is done and its response has started loading in the popup. + * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a + * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is + * done and its response has started loading in the popup. * * ```js * const [popup] = await Promise.all([ @@ -592,29 +667,39 @@ export interface Page { * console.log(await popup.evaluate('location.href')); * ``` * - * > **NOTE** Use [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in most cases). + * > **NOTE** Use + * [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) + * to wait until the page gets to a particular state (you should not need it in most cases). */ once(event: 'popup', listener: (page: Page) => void): this; /** - * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). + * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see + * [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or + * [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). */ once(event: 'request', listener: (request: Request) => void): this; /** * Emitted when a request fails, for example by timing out. * - * > **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with [`page.on('requestfinished')`](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). + * > **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). */ once(event: 'requestfailed', listener: (request: Request) => void): this; /** - * Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when a request finishes successfully after downloading the response body. For a successful response, the + * sequence of events is `request`, `response` and `requestfinished`. */ once(event: 'requestfinished', listener: (request: Request) => void): this; /** - * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events + * is `request`, `response` and `requestfinished`. */ once(event: 'response', listener: (response: Response) => void): this; @@ -624,7 +709,8 @@ export interface Page { once(event: 'websocket', listener: (webSocket: WebSocket) => void): this; /** - * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page. + * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the + * page. */ once(event: 'worker', listener: (worker: Worker) => void): this; @@ -634,7 +720,8 @@ export interface Page { addListener(event: 'close', listener: () => void): this; /** - * 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. + * 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. * * The arguments passed into `console.log` appear as arguments on the event handler. * @@ -652,7 +739,8 @@ export interface Page { addListener(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** - * 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. + * 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. * * The most common way to deal with crashes is to catch an exception: * @@ -667,7 +755,8 @@ export interface Page { * } * ``` * - * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, handling `crash` event helps: + * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, + * handling `crash` event helps: * * ```js * await new Promise((resolve, reject) => { @@ -683,24 +772,34 @@ export interface Page { addListener(event: 'crash', listener: () => void): this; /** - * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. + * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond + * to the dialog via + * [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) + * or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. */ addListener(event: 'dialog', listener: (dialog: Dialog) => void): this; /** - * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched. + * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) + * event is dispatched. */ addListener(event: 'domcontentloaded', listener: () => void): this; /** - * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance. + * 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 or set to `false`, 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; /** - * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can respond to it via setting the input files using [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) that can be uploaded after that. + * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can + * respond to it via setting the input files using + * [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) + * that can be uploaded after that. * * ```js * page.on('filechooser', async (fileChooser) => { @@ -737,9 +836,13 @@ export interface Page { addListener(event: 'pageerror', listener: (error: Error) => void): this; /** - * Emitted when the page opens a new tab or window. This event is emitted in addition to the [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but only for popups relevant to this page. + * Emitted when the page opens a new tab or window. This event is emitted in addition to the + * [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but + * only for popups relevant to this page. * - * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is done and its response has started loading in the popup. + * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a + * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is + * done and its response has started loading in the popup. * * ```js * const [popup] = await Promise.all([ @@ -749,29 +852,39 @@ export interface Page { * console.log(await popup.evaluate('location.href')); * ``` * - * > **NOTE** Use [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in most cases). + * > **NOTE** Use + * [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) + * to wait until the page gets to a particular state (you should not need it in most cases). */ addListener(event: 'popup', listener: (page: Page) => void): this; /** - * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). + * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see + * [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or + * [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). */ addListener(event: 'request', listener: (request: Request) => void): this; /** * Emitted when a request fails, for example by timing out. * - * > **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with [`page.on('requestfinished')`](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). + * > **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). */ addListener(event: 'requestfailed', listener: (request: Request) => void): this; /** - * Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when a request finishes successfully after downloading the response body. For a successful response, the + * sequence of events is `request`, `response` and `requestfinished`. */ addListener(event: 'requestfinished', listener: (request: Request) => void): this; /** - * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events + * is `request`, `response` and `requestfinished`. */ addListener(event: 'response', listener: (response: Response) => void): this; @@ -781,7 +894,8 @@ export interface Page { addListener(event: 'websocket', listener: (webSocket: WebSocket) => void): this; /** - * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page. + * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the + * page. */ addListener(event: 'worker', listener: (worker: Worker) => void): this; @@ -791,7 +905,8 @@ export interface Page { removeListener(event: 'close', listener: () => void): this; /** - * 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. + * 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. * * The arguments passed into `console.log` appear as arguments on the event handler. * @@ -809,7 +924,8 @@ export interface Page { removeListener(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** - * 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. + * 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. * * The most common way to deal with crashes is to catch an exception: * @@ -824,7 +940,8 @@ export interface Page { * } * ``` * - * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, handling `crash` event helps: + * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, + * handling `crash` event helps: * * ```js * await new Promise((resolve, reject) => { @@ -840,24 +957,34 @@ export interface Page { removeListener(event: 'crash', listener: () => void): this; /** - * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. + * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond + * to the dialog via + * [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) + * or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. */ removeListener(event: 'dialog', listener: (dialog: Dialog) => void): this; /** - * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched. + * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) + * event is dispatched. */ removeListener(event: 'domcontentloaded', listener: () => void): this; /** - * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance. + * 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 or set to `false`, 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; /** - * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can respond to it via setting the input files using [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) that can be uploaded after that. + * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can + * respond to it via setting the input files using + * [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) + * that can be uploaded after that. * * ```js * page.on('filechooser', async (fileChooser) => { @@ -894,9 +1021,13 @@ export interface Page { removeListener(event: 'pageerror', listener: (error: Error) => void): this; /** - * Emitted when the page opens a new tab or window. This event is emitted in addition to the [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but only for popups relevant to this page. + * Emitted when the page opens a new tab or window. This event is emitted in addition to the + * [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but + * only for popups relevant to this page. * - * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is done and its response has started loading in the popup. + * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a + * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is + * done and its response has started loading in the popup. * * ```js * const [popup] = await Promise.all([ @@ -906,29 +1037,39 @@ export interface Page { * console.log(await popup.evaluate('location.href')); * ``` * - * > **NOTE** Use [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in most cases). + * > **NOTE** Use + * [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) + * to wait until the page gets to a particular state (you should not need it in most cases). */ removeListener(event: 'popup', listener: (page: Page) => void): this; /** - * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). + * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see + * [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or + * [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). */ removeListener(event: 'request', listener: (request: Request) => void): this; /** * Emitted when a request fails, for example by timing out. * - * > **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with [`page.on('requestfinished')`](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). + * > **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). */ removeListener(event: 'requestfailed', listener: (request: Request) => void): this; /** - * Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when a request finishes successfully after downloading the response body. For a successful response, the + * sequence of events is `request`, `response` and `requestfinished`. */ removeListener(event: 'requestfinished', listener: (request: Request) => void): this; /** - * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events + * is `request`, `response` and `requestfinished`. */ removeListener(event: 'response', listener: (response: Response) => void): this; @@ -938,7 +1079,8 @@ export interface Page { removeListener(event: 'websocket', listener: (webSocket: WebSocket) => void): this; /** - * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page. + * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the + * page. */ removeListener(event: 'worker', listener: (worker: Worker) => void): this; @@ -948,7 +1090,8 @@ export interface Page { off(event: 'close', listener: () => void): this; /** - * 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. + * 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. * * The arguments passed into `console.log` appear as arguments on the event handler. * @@ -966,7 +1109,8 @@ export interface Page { off(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** - * 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. + * 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. * * The most common way to deal with crashes is to catch an exception: * @@ -981,7 +1125,8 @@ export interface Page { * } * ``` * - * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, handling `crash` event helps: + * However, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, + * handling `crash` event helps: * * ```js * await new Promise((resolve, reject) => { @@ -997,24 +1142,34 @@ export interface Page { off(event: 'crash', listener: () => void): this; /** - * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. + * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond + * to the dialog via + * [`dialog.accept([promptText])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogacceptprompttext) + * or [`dialog.dismiss()`](https://github.com/microsoft/playwright/blob/master/docs/api.md#dialogdismiss) methods. */ off(event: 'dialog', listener: (dialog: Dialog) => void): this; /** - * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched. + * Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) + * event is dispatched. */ off(event: 'domcontentloaded', listener: () => void): this; /** - * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance. + * 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 or set to `false`, 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; /** - * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can respond to it via setting the input files using [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) that can be uploaded after that. + * Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can + * respond to it via setting the input files using + * [`fileChooser.setFiles(files[, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#filechoosersetfilesfiles-options) + * that can be uploaded after that. * * ```js * page.on('filechooser', async (fileChooser) => { @@ -1051,9 +1206,13 @@ export interface Page { off(event: 'pageerror', listener: (error: Error) => void): this; /** - * Emitted when the page opens a new tab or window. This event is emitted in addition to the [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but only for popups relevant to this page. + * Emitted when the page opens a new tab or window. This event is emitted in addition to the + * [`browserContext.on('page')`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextonpage), but + * only for popups relevant to this page. * - * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is done and its response has started loading in the popup. + * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a + * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is + * done and its response has started loading in the popup. * * ```js * const [popup] = await Promise.all([ @@ -1063,29 +1222,39 @@ export interface Page { * console.log(await popup.evaluate('location.href')); * ``` * - * > **NOTE** Use [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) to wait until the page gets to a particular state (you should not need it in most cases). + * > **NOTE** Use + * [`page.waitForLoadState([state, options])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforloadstatestate-options) + * to wait until the page gets to a particular state (you should not need it in most cases). */ off(event: 'popup', listener: (page: Page) => void): this; /** - * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). + * Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see + * [`page.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagerouteurl-handler) or + * [`browserContext.route(url, handler)`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextrouteurl-handler). */ off(event: 'request', listener: (request: Request) => void): this; /** * Emitted when a request fails, for example by timing out. * - * > **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with [`page.on('requestfinished')`](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). + * > **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). */ off(event: 'requestfailed', listener: (request: Request) => void): this; /** - * Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when a request finishes successfully after downloading the response body. For a successful response, the + * sequence of events is `request`, `response` and `requestfinished`. */ off(event: 'requestfinished', listener: (request: Request) => void): this; /** - * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`. + * Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events + * is `request`, `response` and `requestfinished`. */ off(event: 'response', listener: (response: Response) => void): this; @@ -1095,7 +1264,8 @@ export interface Page { off(event: 'websocket', listener: (webSocket: WebSocket) => void): this; /** - * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page. + * Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the + * page. */ off(event: 'worker', listener: (worker: Worker) => void): this; @@ -1104,9 +1274,11 @@ export interface Page { /** * Adds a script which would be evaluated in one of the following scenarios: * - Whenever the page is navigated. - * - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame. + * - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly + * attached frame. * - * The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed `Math.random`. + * The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend + * the JavaScript environment, e.g. to seed `Math.random`. * * An example of overriding `Math.random` before the page loads: * @@ -1119,13 +1291,18 @@ export interface Page { * await page.addInitScript(preloadFile); * ``` * - * > **NOTE** The order of evaluation of multiple scripts installed via [`browserContext.addInitScript(script[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextaddinitscriptscript-arg) and [`page.addInitScript(script[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageaddinitscriptscript-arg) is not defined. + * > **NOTE** The order of evaluation of multiple scripts installed via + * [`browserContext.addInitScript(script[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextaddinitscriptscript-arg) + * and + * [`page.addInitScript(script[, arg])`](https://github.com/microsoft/playwright/blob/master/docs/api.md#pageaddinitscriptscript-arg) + * is not defined. * @param script Script to be evaluated in the page. * @param arg Optional argument to pass to `script` (only supported when passing a function). */ addInitScript(script: Function|string|{ /** - * Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. Optional. + * Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working + * directory. Optional. */ path?: string; @@ -1136,9 +1313,11 @@ export interface Page { }, arg?: Serializable): Promise; /** - * Adds a `