diff --git a/docs-src/api-body.md b/docs-src/api-body.md index 68b514db89..90a9ea1a5c 100644 --- a/docs-src/api-body.md +++ b/docs-src/api-body.md @@ -27,7 +27,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 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). ```js const { webkit, devices } = require('playwright'); @@ -49,7 +49,7 @@ const iPhone = devices['iPhone 6']; - type: <[Object]> - `TimeoutError` <[function]> A class of [TimeoutError]. -Playwright methods might throw errors if they are unable to fulfill a request. For example, [`method: Page.waitForSelector`]() +Playwright methods might throw errors if they are unable to fulfill a request. For example, [`method: Page.waitForSelector`] might fail if the selector doesn't match any nodes during the given timeframe. For certain types of errors Playwright uses specific error classes. @@ -84,8 +84,8 @@ This object can be used to launch or connect to WebKit, returning instances of [ # class: Browser * extends: [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) -A Browser is created when Playwright connects to a browser instance, either through [`method: BrowserType.launch`]() or -[`method: BrowserType.connect`](). +A Browser is created when Playwright connects to a browser instance, either through [`method: BrowserType.launch`] or +[`method: BrowserType.connect`]. An example of using a [Browser] to create a [Page]: @@ -101,7 +101,7 @@ const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'. ``` See [ChromiumBrowser], [FirefoxBrowser] and [WebKitBrowser] for browser-specific features. Note that [`method: -BrowserType.connect`]() and [`method: BrowserType.launch`]() always return a specific browser instance, based on the +BrowserType.connect`] and [`method: BrowserType.launch`] always return a specific browser instance, based on the browser being connected to or launched. @@ -111,14 +111,14 @@ browser being connected to or launched. Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following: * Browser application is closed or crashed. -* The [`method: Browser.close`]() method was called. +* The [`method: Browser.close`] method was called. ## async method: Browser.close -In case this browser is obtained using [`method: BrowserType.launch`](), closes the browser and all of its pages (if any +In case this browser is obtained using [`method: BrowserType.launch`], closes the browser and all of its pages (if any were opened). -In case this browser is obtained using [`method: BrowserType.connect`](), clears all created contexts belonging to this +In case this browser is obtained using [`method: BrowserType.connect`], clears all created contexts belonging to this browser and disconnects from the browser server. The [Browser] object itself is considered to be disposed and cannot be used anymore. @@ -169,8 +169,8 @@ Creates a new browser context. It won't share cookies/cache with other browser c Creates a new page in a new browser context. Closing this page will close the context as well. This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and -testing frameworks should explicitly create [`method: Browser.newContext`]() followed by the [`method: -BrowserContext.newPage`]() to control their exact life times. +testing frameworks should explicitly create [`method: Browser.newContext`] followed by the [`method: +BrowserContext.newPage`] to control their exact life times. ### option: Browser.newPage.-inline- = %%-shared-context-params-list-%% @@ -212,13 +212,13 @@ await context.close(); Emitted when Browser context gets closed. This might happen because of one of the following: * Browser context is closed. * Browser application is closed or crashed. -* The [`method: Browser.close`]() method was called. +* The [`method: Browser.close`] method was called. ## event: BrowserContext.page - type: <[Page]> The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will -also fire for popup pages. See also [`event: Page.popup`]() to receive events about popups relevant to a specific page. +also fire for popup pages. See also [`event: Page.popup`] to receive events about popups relevant to a specific 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 @@ -232,13 +232,13 @@ 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 Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be -obtained via [`method: BrowserContext.cookies`](). +obtained via [`method: BrowserContext.cookies`]. ```js await browserContext.addCookies([cookieObject1, cookieObject2]); @@ -279,8 +279,8 @@ await browserContext.addInitScript({ }); ``` -> **NOTE** The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`]() and -[`method: Page.addInitScript`]() is not defined. +> **NOTE** The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and +[`method: Page.addInitScript`] is not defined. ### param: BrowserContext.addInitScript.script - `script` <[function]|[string]|[Object]> @@ -292,7 +292,7 @@ Script to be evaluated in all pages in the browser context. ### param: BrowserContext.addInitScript.arg - `arg` <[Serializable]> -Optional argument to pass to [`param: script`]() (only supported when passing a function). +Optional argument to pass to [`param: script`] (only supported when passing a function). ## method: BrowserContext.browser - returns: <[null]|[Browser]> @@ -341,14 +341,14 @@ Optional list of URLs. ## async method: BrowserContext.exposeBinding -The method adds a function called [`param: name`]() on the `window` object of every frame in every page in the context. -When called, the function executes [`param: playwrightBinding`]() and returns a [Promise] which resolves to the return -value of [`param: playwrightBinding`](). If the [`param: playwrightBinding`]() returns a [Promise], it will be awaited. +The method adds a function called [`param: name`] on the `window` object of every frame in every page in the context. +When called, the function executes [`param: playwrightBinding`] and returns a [Promise] which resolves to the return +value of [`param: playwrightBinding`]. If the [`param: playwrightBinding`] returns a [Promise], it will be awaited. -The first argument of the [`param: playwrightBinding`]() function contains information about the caller: `{ +The first argument of the [`param: playwrightBinding`] function contains information about the caller: `{ browserContext: BrowserContext, page: Page, frame: Frame }`. -See [`method: Page.exposeBinding`]() for page-only version. +See [`method: Page.exposeBinding`] for page-only version. An example of exposing page URL to all frames in all pages in the context: @@ -406,13 +406,13 @@ supported. When passing by value, multiple arguments are supported. ## async method: BrowserContext.exposeFunction -The method adds a function called [`param: name`]() on the `window` object of every frame in every page in the context. -When called, the function executes [`param: playwrightFunction`]() and returns a [Promise] which resolves to the return -value of [`param: playwrightFunction`](). +The method adds a function called [`param: name`] on the `window` object of every frame in every page in the context. +When called, the function executes [`param: playwrightFunction`] and returns a [Promise] which resolves to the return +value of [`param: playwrightFunction`]. -If the [`param: playwrightFunction`]() returns a [Promise], it will be awaited. +If the [`param: playwrightFunction`] returns a [Promise], it will be awaited. -See [`method: Page.exposeFunction`]() for page-only version. +See [`method: Page.exposeFunction`] for page-only version. An example of adding an `md5` function to all pages in the context: @@ -488,7 +488,7 @@ Creates a new page in the browser context. - returns: <[Array]<[Page]>> Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can -find them using [`method: ChromiumBrowserContext.backgroundPages`](). +find them using [`method: ChromiumBrowserContext.backgroundPages`]. ## async method: BrowserContext.route @@ -515,7 +515,7 @@ await page.goto('https://example.com'); await browser.close(); ``` -Page routes (set up with [`method: Page.route`]()) take precedence over browser context routes when request matches both +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. @@ -533,15 +533,15 @@ handler function to route the request. ## method: BrowserContext.setDefaultNavigationTimeout This setting will change the default maximum navigation time for the following methods and related shortcuts: -* [`method: Page.goBack`]() -* [`method: Page.goForward`]() -* [`method: Page.goto`]() -* [`method: Page.reload`]() -* [`method: Page.setContent`]() -* [`method: Page.waitForNavigation`]() +* [`method: Page.goBack`] +* [`method: Page.goForward`] +* [`method: Page.goto`] +* [`method: Page.reload`] +* [`method: Page.setContent`] +* [`method: Page.waitForNavigation`] -> **NOTE** [`method: Page.setDefaultNavigationTimeout`]() and [`method: Page.setDefaultTimeout`]() take priority over -[`method: BrowserContext.setDefaultNavigationTimeout`](). +> **NOTE** [`method: Page.setDefaultNavigationTimeout`] and [`method: Page.setDefaultTimeout`] take priority over +[`method: BrowserContext.setDefaultNavigationTimeout`]. ### param: BrowserContext.setDefaultNavigationTimeout.timeout - `timeout` <[number]> @@ -550,10 +550,10 @@ Maximum navigation time in milliseconds ## method: BrowserContext.setDefaultTimeout -This setting will change the default maximum time for all the methods accepting [`param: timeout`]() option. +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: -BrowserContext.setDefaultNavigationTimeout`]() take priority over [`method: BrowserContext.setDefaultTimeout`](). +> **NOTE** [`method: Page.setDefaultNavigationTimeout`], [`method: Page.setDefaultTimeout`] and [`method: +BrowserContext.setDefaultNavigationTimeout`] take priority over [`method: BrowserContext.setDefaultTimeout`]. ### param: BrowserContext.setDefaultTimeout.timeout - `timeout` <[number]> @@ -563,7 +563,7 @@ Maximum time in milliseconds ## async method: BrowserContext.setExtraHTTPHeaders The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged -with page-specific extra HTTP headers set with [`method: Page.setExtraHTTPHeaders`](). If page overrides a particular +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. @@ -581,7 +581,7 @@ 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 @@ -632,25 +632,25 @@ Returns storage state for this browser context, contains current cookies and loc ### option: BrowserContext.storageState.path - `path` <[string]> -The file path to save the storage state to. If [`option: path`]() is a relative path, then it is resolved relative to +The file path to save the storage state to. If [`option: path`] is a relative path, then it is resolved relative to [current working directory](https://nodejs.org/api/process.html#process_process_cwd). If no path is provided, storage state is still returned, but won't be saved to the disk. ## async method: BrowserContext.unroute -Removes a route created with [`method: BrowserContext.route`](). When [`param: handler`]() is not specified, removes all -routes for the [`param: url`](). +Removes a route created with [`method: BrowserContext.route`]. When [`param: handler`] is not specified, removes all +routes for the [`param: url`]. ### param: BrowserContext.unroute.url - `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with [`method: -BrowserContext.route`](). +BrowserContext.route`]. ### param: BrowserContext.unroute.handler - `handler` <[function]\([Route], [Request]\)> -Optional handler function used to register a routing with [`method: BrowserContext.route`](). +Optional handler function used to register a routing with [`method: BrowserContext.route`]. ## async method: BrowserContext.waitForEvent - returns: <[Object]> @@ -671,7 +671,7 @@ Event name, same one would pass into `browserContext.on(event)`. ### param: BrowserContext.waitForEvent.optionsOrPredicate - `optionsOrPredicate` <[Function]|[Object]> - `predicate` <[Function]> receives the event data and resolves to truthy value when the waiting should resolve. - - `timeout` <[number]> 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 [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout). + - `timeout` <[number]> 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. @@ -778,7 +778,7 @@ await new Promise((resolve, reject) => { - type: <[Dialog]> Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond -to the dialog via [`method: Dialog.accept`]() or [`method: Dialog.dismiss`]() methods. +to the dialog via [`method: Dialog.accept`] or [`method: Dialog.dismiss`] methods. ## event: Page.domcontentloaded @@ -799,7 +799,7 @@ download is not performed and user has no access to the downloaded files. - type: <[FileChooser]> Emitted when a file chooser is supposed to appear, such as after clicking the ``. Playwright can -respond to it via setting the input files using [`method: FileChooser.setFiles`]() that can be uploaded after that. +respond to it via setting the input files using [`method: FileChooser.setFiles`] that can be uploaded after that. ```js page.on('filechooser', async (fileChooser) => { @@ -835,7 +835,7 @@ Emitted when an uncaught exception happens within the page. - type: <[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. +BrowserContext.page`], 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 @@ -849,14 +849,14 @@ 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]> 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`](). +[`method: Page.route`] or [`method: BrowserContext.route`]. ## event: Page.requestfailed - type: <[Request]> @@ -864,7 +864,7 @@ 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 -will complete with [`event: Page.requestfinished`]() event and not with [`event: Page.requestfailed`](). +will complete with [`event: Page.requestfinished`] event and not with [`event: Page.requestfailed`]. ## event: Page.requestfinished - type: <[Request]> @@ -895,7 +895,7 @@ page. 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 [`method: Frame.$`](). +Shortcut for main frame's [`method: Frame.$`]. ### param: Page.$.selector = %%-query-selector-%% @@ -905,7 +905,7 @@ Shortcut for main frame's [`method: Frame.$`](). 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 [`method: Frame.$$`](). +Shortcut for main frame's [`method: Frame.$$`]. ### param: Page.$$.selector = %%-query-selector-%% @@ -913,10 +913,10 @@ Shortcut for main frame's [`method: Frame.$$`](). - returns: <[Serializable]> The method finds an element matching the specified selector within the page and passes it as a first argument to -[`param: pageFunction`](). If no elements match the selector, the method throws an error. Returns the value of [`param: -pageFunction`](). +[`param: pageFunction`]. If no elements match the selector, the method throws an error. Returns the value of [`param: +pageFunction`]. -If [`param: pageFunction`]() returns a [Promise], then [`method: Page.$eval`]() would wait for the promise to resolve and return its +If [`param: pageFunction`] returns a [Promise], then [`method: Page.$eval`] would wait for the promise to resolve and return its value. Examples: @@ -927,7 +927,7 @@ const preloadHref = await page.$eval('link[rel=preload]', el => el.href); const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello'); ``` -Shortcut for main frame's [`method: Frame.$eval`](). +Shortcut for main frame's [`method: Frame.$eval`]. ### param: Page.$eval.selector = %%-query-selector-%% @@ -939,15 +939,15 @@ Function to be evaluated in browser context ### param: Page.$eval.arg - `arg` <[EvaluationArgument]> -Optional argument to pass to [`param: pageFunction`]() +Optional argument to pass to [`param: pageFunction`] ## async method: Page.$$eval - returns: <[Serializable]> The method finds all elements matching the specified selector within the page and passes an array of matched elements as -a first argument to [`param: pageFunction`](). Returns the result of [`param: pageFunction`]() invocation. +a first argument to [`param: pageFunction`]. Returns the result of [`param: pageFunction`] invocation. -If [`param: pageFunction`]() returns a [Promise], then [`method: Page.$$eval`]() would wait for the promise to resolve and return +If [`param: pageFunction`] returns a [Promise], then [`method: Page.$$eval`] would wait for the promise to resolve and return its value. Examples: @@ -966,7 +966,7 @@ Function to be evaluated in browser context ### param: Page.$$eval.arg - `arg` <[EvaluationArgument]> -Optional argument to pass to [`param: pageFunction`]() +Optional argument to pass to [`param: pageFunction`] ## property: Page.accessibility - type: <[Accessibility]> @@ -991,8 +991,8 @@ 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 -[`method: Page.addInitScript`]() is not defined. +> **NOTE** The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and +[`method: Page.addInitScript`] is not defined. ### param: Page.addInitScript.script - `script` <[function]|[string]|[Object]> @@ -1004,7 +1004,7 @@ Script to be evaluated in the page. ### param: Page.addInitScript.arg - `arg` <[Serializable]> -Optional argument to pass to [`param: script`]() (only supported when passing a function). +Optional argument to pass to [`param: script`] (only supported when passing a function). ## async method: Page.addScriptTag - returns: <[ElementHandle]> @@ -1012,7 +1012,7 @@ Optional argument to pass to [`param: script`]() (only supported when passing a Adds a `