diff --git a/api.json b/api.json index 4f6cd53df..ebcc764e2 100644 --- a/api.json +++ b/api.json @@ -1 +1 @@ -{"Browser":{"name":"Browser","extends":"EventEmitter","members":{"disconnected":{"kind":"event","name":"disconnected","type":null,"comment":"","returnComment":"","required":true,"args":{}},"close":{"kind":"method","name":"close","type":{"name":"Promise"},"comment":"In case this browser is obtained using browserType.launch, closes the browser and all of its pages (if any were opened).\nIn case this browser is obtained using browserType.connect, clears all created contexts belonging to this browser and disconnects from the browser server.\nThe Browser object itself is considered to be disposed and cannot be used anymore.","returnComment":"","required":true,"args":{}},"contexts":{"kind":"method","name":"contexts","type":{"name":"Array"},"comment":"Returns an array of all open browser contexts. In a newly created browser, this will return zero\nbrowser contexts.\n```js\nconst browser = await pw.webkit.launch();\nconsole.log(browser.contexts().length); // prints `0`\n\nconst context = await browser.newContext();\nconsole.log(browser.contexts().length); // prints `1`\n```","returnComment":"","required":true,"args":{}},"isConnected":{"kind":"method","name":"isConnected","type":{"name":"boolean"},"comment":"Indicates that the browser is connected.","returnComment":"","required":true,"args":{}},"newContext":{"kind":"method","name":"newContext","type":{"name":"Promise"},"comment":"Creates a new browser context. It won't share cookies/cache with other browser contexts.\n```js\n(async () => {\n const browser = await playwright.firefox.launch(); // Or 'chromium' or 'webkit'.\n // Create a new incognito browser context.\n const context = await browser.newContext();\n // Create a new page in a pristine context.\n const page = await context.newPage();\n await page.goto('https://example.com');\n})();\n```","returnComment":"","required":true,"args":{"options":{"kind":"property","name":"options","type":{"name":"Object","properties":{"acceptDownloads":{"kind":"property","name":"acceptDownloads","type":{"name":"boolean"},"comment":"Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.","returnComment":"","required":false},"ignoreHTTPSErrors":{"kind":"property","name":"ignoreHTTPSErrors","type":{"name":"boolean"},"comment":"Whether to ignore HTTPS errors during navigation. Defaults to `false`.","returnComment":"","required":false},"bypassCSP":{"kind":"property","name":"bypassCSP","type":{"name":"boolean"},"comment":"Toggles bypassing page's Content-Security-Policy.","returnComment":"","required":false},"viewport":{"kind":"property","name":"viewport","type":{"name":"null|Object","properties":{"width":{"kind":"property","name":"width","type":{"name":"number"},"comment":"page width in pixels.","returnComment":"","required":true},"height":{"kind":"property","name":"height","type":{"name":"number"},"comment":"page height in pixels.","returnComment":"","required":true}}},"comment":"Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `null` disables the default viewport.","returnComment":"","required":false},"userAgent":{"kind":"property","name":"userAgent","type":{"name":"string"},"comment":"Specific user agent to use in this context.","returnComment":"","required":false},"deviceScaleFactor":{"kind":"property","name":"deviceScaleFactor","type":{"name":"number"},"comment":"Specify device scale factor (can be thought of as dpr). Defaults to `1`.","returnComment":"","required":false},"isMobile":{"kind":"property","name":"isMobile","type":{"name":"boolean"},"comment":"Whether the `meta viewport` tag is taken into account and touch events are enabled. Defaults to `false`. Not supported in Firefox.","returnComment":"","required":false},"hasTouch":{"kind":"property","name":"hasTouch","type":{"name":"boolean"},"comment":"Specifies if viewport supports touch events. Defaults to false.","returnComment":"","required":false},"javaScriptEnabled":{"kind":"property","name":"javaScriptEnabled","type":{"name":"boolean"},"comment":"Whether or not to enable JavaScript in the context. Defaults to true.","returnComment":"","required":false},"timezoneId":{"kind":"property","name":"timezoneId","type":{"name":"string"},"comment":"Changes the timezone of the context. See ICU’s `metaZones.txt` for a list of supported timezone IDs.","returnComment":"","required":false},"geolocation":{"kind":"property","name":"geolocation","type":{"name":"Object","properties":{"latitude":{"kind":"property","name":"latitude","type":{"name":"number"},"comment":"Latitude between -90 and 90.","returnComment":"","required":true},"longitude":{"kind":"property","name":"longitude","type":{"name":"number"},"comment":"Longitude between -180 and 180.","returnComment":"","required":true},"accuracy":{"kind":"property","name":"accuracy","type":{"name":"number"},"comment":"Non-negative accuracy value. Defaults to `0`.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false},"locale":{"kind":"property","name":"locale","type":{"name":"string"},"comment":"Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules.","returnComment":"","required":false},"permissions":{"kind":"property","name":"permissions","type":{"name":"Array"},"comment":"A list of permissions to grant to all pages in this context. See browserContext.grantPermissions for more details.","returnComment":"","required":false},"extraHTTPHeaders":{"kind":"property","name":"extraHTTPHeaders","type":{"name":"Object"},"comment":"An object containing additional HTTP headers to be sent with every request. All header values must be strings.","returnComment":"","required":false},"offline":{"kind":"property","name":"offline","type":{"name":"boolean"},"comment":"Whether to emulate network being offline. Defaults to `false`.","returnComment":"","required":false},"httpCredentials":{"kind":"property","name":"httpCredentials","type":{"name":"Object","properties":{"username":{"kind":"property","name":"username","type":{"name":"string"},"comment":"","returnComment":"","required":true},"password":{"kind":"property","name":"password","type":{"name":"string"},"comment":"","returnComment":"","required":true}}},"comment":"Credentials for HTTP authentication.","returnComment":"","required":false},"colorScheme":{"kind":"property","name":"colorScheme","type":{"name":"\"dark\"|\"light\"|\"no-preference\""},"comment":"Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See page.emulateMedia(options) for more details. Defaults to '`light`'.","returnComment":"","required":false},"logger":{"kind":"property","name":"logger","type":{"name":"Logger"},"comment":"Logger sink for Playwright logging.","returnComment":"","required":false},"videosPath":{"kind":"property","name":"videosPath","type":{"name":"string"},"comment":"Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded.","returnComment":"","required":false},"videoSize":{"kind":"property","name":"videoSize","type":{"name":"Object","properties":{"width":{"kind":"property","name":"width","type":{"name":"number"},"comment":"Video frame width.","returnComment":"","required":true},"height":{"kind":"property","name":"height","type":{"name":"number"},"comment":"Video frame height.","returnComment":"","required":true}}},"comment":"Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false}}},"newPage":{"kind":"method","name":"newPage","type":{"name":"Promise"},"comment":"Creates a new page in a new browser context. Closing this page will close the context as well.\nThis 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 browser.newContext followed by the browserContext.newPage to control their exact life times.","returnComment":"","required":true,"args":{"options":{"kind":"property","name":"options","type":{"name":"Object","properties":{"acceptDownloads":{"kind":"property","name":"acceptDownloads","type":{"name":"boolean"},"comment":"Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.","returnComment":"","required":false},"ignoreHTTPSErrors":{"kind":"property","name":"ignoreHTTPSErrors","type":{"name":"boolean"},"comment":"Whether to ignore HTTPS errors during navigation. Defaults to `false`.","returnComment":"","required":false},"bypassCSP":{"kind":"property","name":"bypassCSP","type":{"name":"boolean"},"comment":"Toggles bypassing page's Content-Security-Policy.","returnComment":"","required":false},"viewport":{"kind":"property","name":"viewport","type":{"name":"null|Object","properties":{"width":{"kind":"property","name":"width","type":{"name":"number"},"comment":"page width in pixels.","returnComment":"","required":true},"height":{"kind":"property","name":"height","type":{"name":"number"},"comment":"page height in pixels.","returnComment":"","required":true}}},"comment":"Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `null` disables the default viewport.","returnComment":"","required":false},"userAgent":{"kind":"property","name":"userAgent","type":{"name":"string"},"comment":"Specific user agent to use in this context.","returnComment":"","required":false},"deviceScaleFactor":{"kind":"property","name":"deviceScaleFactor","type":{"name":"number"},"comment":"Specify device scale factor (can be thought of as dpr). Defaults to `1`.","returnComment":"","required":false},"isMobile":{"kind":"property","name":"isMobile","type":{"name":"boolean"},"comment":"Whether the `meta viewport` tag is taken into account and touch events are enabled. Defaults to `false`. Not supported in Firefox.","returnComment":"","required":false},"hasTouch":{"kind":"property","name":"hasTouch","type":{"name":"boolean"},"comment":"Specifies if viewport supports touch events. Defaults to false.","returnComment":"","required":false},"javaScriptEnabled":{"kind":"property","name":"javaScriptEnabled","type":{"name":"boolean"},"comment":"Whether or not to enable JavaScript in the context. Defaults to `true`.","returnComment":"","required":false},"timezoneId":{"kind":"property","name":"timezoneId","type":{"name":"string"},"comment":"Changes the timezone of the context. See ICU’s `metaZones.txt` for a list of supported timezone IDs.","returnComment":"","required":false},"geolocation":{"kind":"property","name":"geolocation","type":{"name":"Object","properties":{"latitude":{"kind":"property","name":"latitude","type":{"name":"number"},"comment":"Latitude between -90 and 90.","returnComment":"","required":true},"longitude":{"kind":"property","name":"longitude","type":{"name":"number"},"comment":"Longitude between -180 and 180.","returnComment":"","required":true},"accuracy":{"kind":"property","name":"accuracy","type":{"name":"number"},"comment":"Non-negative accuracy value. Defaults to `0`.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false},"locale":{"kind":"property","name":"locale","type":{"name":"string"},"comment":"Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules.","returnComment":"","required":false},"permissions":{"kind":"property","name":"permissions","type":{"name":"Array"},"comment":"A list of permissions to grant to all pages in this context. See browserContext.grantPermissions for more details.","returnComment":"","required":false},"extraHTTPHeaders":{"kind":"property","name":"extraHTTPHeaders","type":{"name":"Object"},"comment":"An object containing additional HTTP headers to be sent with every request. All header values must be strings.","returnComment":"","required":false},"offline":{"kind":"property","name":"offline","type":{"name":"boolean"},"comment":"Whether to emulate network being offline. Defaults to `false`.","returnComment":"","required":false},"httpCredentials":{"kind":"property","name":"httpCredentials","type":{"name":"Object","properties":{"username":{"kind":"property","name":"username","type":{"name":"string"},"comment":"","returnComment":"","required":true},"password":{"kind":"property","name":"password","type":{"name":"string"},"comment":"","returnComment":"","required":true}}},"comment":"Credentials for HTTP authentication.","returnComment":"","required":false},"colorScheme":{"kind":"property","name":"colorScheme","type":{"name":"\"dark\"|\"light\"|\"no-preference\""},"comment":"Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See page.emulateMedia(options) for more details. Defaults to '`light`'.","returnComment":"","required":false},"logger":{"kind":"property","name":"logger","type":{"name":"Logger"},"comment":"Logger sink for Playwright logging.","returnComment":"","required":false},"videosPath":{"kind":"property","name":"videosPath","type":{"name":"string"},"comment":"Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded.","returnComment":"","required":false},"videoSize":{"kind":"property","name":"videoSize","type":{"name":"Object","properties":{"width":{"kind":"property","name":"width","type":{"name":"number"},"comment":"Video frame width.","returnComment":"","required":true},"height":{"kind":"property","name":"height","type":{"name":"number"},"comment":"Video frame height.","returnComment":"","required":true}}},"comment":"Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false}}},"version":{"kind":"method","name":"version","type":{"name":"string"},"comment":"Returns the browser version.","returnComment":"","required":true,"args":{}}}},"BrowserContext":{"name":"BrowserContext","extends":"EventEmitter","members":{"close":{"kind":"method","name":"close","type":{"name":"Promise"},"comment":"Closes the browser context. All the pages that belong to the browser context\nwill be closed.\n\n**NOTE** the default browser context cannot be closed.","returnComment":"","required":true,"args":{}},"page":{"kind":"event","name":"page","type":{"name":"Page"},"comment":"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 `Page.on('popup')` to receive events about popups relevant to a specific page.\nThe 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.\n```js\nconst [page] = await Promise.all([\n context.waitForEvent('page'),\n page.click('a[target=_blank]'),\n]);\nconsole.log(await page.evaluate('location.href'));\n```\n\n**NOTE** Use `page.waitForLoadState([state[, options]])` to wait until the page gets to a particular state (you should not need it in most cases).","returnComment":"","required":true,"args":{}},"addCookies":{"kind":"method","name":"addCookies","type":{"name":"Promise"},"comment":"```js\nawait browserContext.addCookies([cookieObject1, cookieObject2]);\n```","returnComment":"","required":true,"args":{"cookies":{"kind":"property","name":"cookies","type":{"name":"Array","properties":{"name":{"kind":"property","name":"name","type":{"name":"string"},"comment":"**required**","returnComment":"","required":true},"value":{"kind":"property","name":"value","type":{"name":"string"},"comment":"**required**","returnComment":"","required":true},"url":{"kind":"property","name":"url","type":{"name":"string"},"comment":"either url or domain / path are required","returnComment":"","required":false},"domain":{"kind":"property","name":"domain","type":{"name":"string"},"comment":"either url or domain / path are required","returnComment":"","required":false},"path":{"kind":"property","name":"path","type":{"name":"string"},"comment":"either url or domain / path are required","returnComment":"","required":false},"expires":{"kind":"property","name":"expires","type":{"name":"number"},"comment":"Unix time in seconds.","returnComment":"","required":false},"httpOnly":{"kind":"property","name":"httpOnly","type":{"name":"boolean"},"comment":"","returnComment":"","required":false},"secure":{"kind":"property","name":"secure","type":{"name":"boolean"},"comment":"","returnComment":"","required":false},"sameSite":{"kind":"property","name":"sameSite","type":{"name":"\"Lax\"|\"None\"|\"Strict\""},"comment":"","returnComment":"","required":false}}},"comment":"","returnComment":"","required":true}}},"addInitScript":{"kind":"method","name":"addInitScript","type":{"name":"Promise"},"comment":"Adds a script which would be evaluated in one of the following scenarios:\n\nWhenever a page is created in the browser context or is navigated.\nWhenever a child frame is attached or navigated in any page in the browser context. In this case, the script is evaluated in the context of the newly attached frame.\n\nThe 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`.\nAn example of overriding `Math.random` before the page loads:\n```js\n// preload.js\nMath.random = () => 42;\n```\n```js\n// In your playwright script, assuming the preload.js file is in same folder.\nawait browserContext.addInitScript({\n path: 'preload.js'\n});\n```\n\n**NOTE** The order of evaluation of multiple scripts installed via browserContext.addInitScript(script[, arg]) and page.addInitScript(script[, arg]) is not defined.","returnComment":"","required":true,"args":{"script":{"kind":"property","name":"script","type":{"name":"function|string|Object","properties":{"path":{"kind":"property","name":"path","type":{"name":"string"},"comment":"Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to current working directory.","returnComment":"","required":false},"content":{"kind":"property","name":"content","type":{"name":"string"},"comment":"Raw script content.","returnComment":"","required":false}}},"comment":"Script to be evaluated in all pages in the browser context.","returnComment":"","required":true},"arg":{"kind":"property","name":"arg","type":{"name":"Serializable"},"comment":"Optional argument to pass to `script` (only supported when passing a function).","returnComment":"","required":false}}},"browser":{"kind":"method","name":"browser","type":{"name":"null|Browser"},"comment":"","returnComment":"Returns the browser instance of the context. If it was launched as a persistent context null gets returned.","required":true,"args":{}},"clearCookies":{"kind":"method","name":"clearCookies","type":{"name":"Promise"},"comment":"Clears context cookies.","returnComment":"","required":true,"args":{}},"clearPermissions":{"kind":"method","name":"clearPermissions","type":{"name":"Promise"},"comment":"Clears all permission overrides for the browser context.\n```js\nconst context = await browser.newContext();\nawait context.grantPermissions(['clipboard-read']);\n// do stuff ..\ncontext.clearPermissions();\n```","returnComment":"","required":true,"args":{}},"cookies":{"kind":"method","name":"cookies","type":{"name":"Promise>","properties":{"name":{"kind":"property","name":"name","type":{"name":"string"},"comment":"","returnComment":"","required":true},"value":{"kind":"property","name":"value","type":{"name":"string"},"comment":"","returnComment":"","required":true},"domain":{"kind":"property","name":"domain","type":{"name":"string"},"comment":"","returnComment":"","required":true},"path":{"kind":"property","name":"path","type":{"name":"string"},"comment":"","returnComment":"","required":true},"expires":{"kind":"property","name":"expires","type":{"name":"number"},"comment":"Unix time in seconds.","returnComment":"","required":true},"httpOnly":{"kind":"property","name":"httpOnly","type":{"name":"boolean"},"comment":"","returnComment":"","required":true},"secure":{"kind":"property","name":"secure","type":{"name":"boolean"},"comment":"","returnComment":"","required":true},"sameSite":{"kind":"property","name":"sameSite","type":{"name":"\"Lax\"|\"None\"|\"Strict\""},"comment":"","returnComment":"","required":true}}},"comment":"If no URLs are specified, this method returns all cookies.\nIf URLs are specified, only cookies that affect those URLs are returned.","returnComment":"","required":true,"args":{"urls":{"kind":"property","name":"urls","type":{"name":"string|Array"},"comment":"","returnComment":"","required":false}}},"exposeBinding":{"kind":"method","name":"exposeBinding","type":{"name":"Promise"},"comment":"The method adds a function called `name` on the `window` object of every frame in every page in the context.\nWhen called, the function executes `playwrightBinding` in Node.js and returns a Promise which resolves to the return value of `playwrightBinding`.\nIf the `playwrightBinding` returns a Promise, it will be awaited.\nThe first argument of the `playwrightBinding` function contains information about the caller:\n`{ browserContext: BrowserContext, page: Page, frame: Frame }`.\nSee page.exposeBinding(name, playwrightBinding) for page-only version.\nAn example of exposing page URL to all frames in all pages in the context:\n```js\nconst { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.\n\n(async () => {\n const browser = await webkit.launch({ headless: false });\n const context = await browser.newContext();\n await context.exposeBinding('pageURL', ({ page }) => page.url());\n const page = await context.newPage();\n await page.setContent(`\n \n \n
\n `);\n await page.click('button');\n})();\n```\nAn example of passing an element handle:\n```js\nawait context.exposeBinding('clicked', async (source, element) => {\n console.log(await element.textContent());\n}, { handle: true });\nawait page.setContent(`\n \n
Click me
\n
Or click me
\n`);\n```","returnComment":"","required":true,"args":{"name":{"kind":"property","name":"name","type":{"name":"string"},"comment":"Name of the function on the window object.","returnComment":"","required":true},"playwrightBinding":{"kind":"property","name":"playwrightBinding","type":{"name":"function"},"comment":"Callback function that will be called in the Playwright's context.","returnComment":"","required":true},"options":{"kind":"property","name":"options","type":{"name":"Object","properties":{"handle":{"kind":"property","name":"handle","type":{"name":"boolean"},"comment":"Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is supported. When passing by value, multiple arguments are supported.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false}}},"exposeFunction":{"kind":"method","name":"exposeFunction","type":{"name":"Promise"},"comment":"The method adds a function called `name` on the `window` object of every frame in every page in the context.\nWhen called, the function executes `playwrightFunction` in Node.js and returns a Promise which resolves to the return value of `playwrightFunction`.\nIf the `playwrightFunction` returns a Promise, it will be awaited.\nSee page.exposeFunction(name, playwrightFunction) for page-only version.\nAn example of adding an `md5` function to all pages in the context:\n```js\nconst { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.\nconst crypto = require('crypto');\n\n(async () => {\n const browser = await webkit.launch({ headless: false });\n const context = await browser.newContext();\n await context.exposeFunction('md5', text => crypto.createHash('md5').update(text).digest('hex'));\n const page = await context.newPage();\n await page.setContent(`\n \n \n
\n `);\n await page.click('button');\n})();\n```","returnComment":"","required":true,"args":{"name":{"kind":"property","name":"name","type":{"name":"string"},"comment":"Name of the function on the window object.","returnComment":"","required":true},"playwrightFunction":{"kind":"property","name":"playwrightFunction","type":{"name":"function"},"comment":"Callback function that will be called in the Playwright's context.","returnComment":"","required":true}}},"grantPermissions":{"kind":"method","name":"grantPermissions","type":{"name":"Promise"},"comment":"Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if specified.","returnComment":"","required":true,"args":{"permissions":{"kind":"property","name":"permissions","type":{"name":"Array"},"comment":"A permission or an array of permissions to grant. Permissions can be one of the following values:\n - `'*'`\n - `'geolocation'`\n - `'midi'`\n - `'midi-sysex'` (system-exclusive midi)\n - `'notifications'`\n - `'push'`\n - `'camera'`\n - `'microphone'`\n - `'background-sync'`\n - `'ambient-light-sensor'`\n - `'accelerometer'`\n - `'gyroscope'`\n - `'magnetometer'`\n - `'accessibility-events'`\n - `'clipboard-read'`\n - `'clipboard-write'`\n - `'payment-handler'`","returnComment":"","required":true},"options":{"kind":"property","name":"options","type":{"name":"Object","properties":{"origin":{"kind":"property","name":"origin","type":{"name":"string"},"comment":"The origin to grant permissions to, e.g. \"https://example.com\".","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false}}},"newPage":{"kind":"method","name":"newPage","type":{"name":"Promise"},"comment":"Creates a new page in the browser context.","returnComment":"","required":true,"args":{}},"pages":{"kind":"method","name":"pages","type":{"name":"Array"},"comment":"","returnComment":"All open pages in the context. Non visible pages, such as `\"background_page\"`, will not be listed here. You can find them using chromiumBrowserContext.backgroundPages().","required":true,"args":{}},"route":{"kind":"method","name":"route","type":{"name":"Promise"},"comment":"Routing provides the capability to modify network requests that are made by any page in the browser context.\nOnce route is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.\nAn example of a naïve handler that aborts all image requests:\n```js\nconst context = await browser.newContext();\nawait context.route('**/*.{png,jpg,jpeg}', route => route.abort());\nconst page = await context.newPage();\nawait page.goto('https://example.com');\nawait browser.close();\n```\nor the same snippet using a regex pattern instead:\n```js\nconst context = await browser.newContext();\nawait context.route(/(\\.png$)|(\\.jpg$)/, route => route.abort());\nconst page = await context.newPage();\nawait page.goto('https://example.com');\nawait browser.close();\n```\nPage routes (set up with page.route(url, handler)) take precedence over browser context routes when request matches both handlers.\n\n**NOTE** Enabling routing disables http cache.","returnComment":"","required":true,"args":{"url":{"kind":"property","name":"url","type":{"name":"string|RegExp|function(URL):boolean"},"comment":"A glob pattern, regex pattern or predicate receiving URL to match while routing.","returnComment":"","required":true},"handler":{"kind":"property","name":"handler","type":{"name":"function(Route, Request)"},"comment":"handler function to route the request.","returnComment":"","required":true}}},"setDefaultNavigationTimeout":{"kind":"method","name":"setDefaultNavigationTimeout","type":null,"comment":"This setting will change the default maximum navigation time for the following methods and related shortcuts:\n\npage.goBack([options])\npage.goForward([options])\npage.goto(url[, options])\npage.reload([options])\npage.setContent(html[, options])\npage.waitForNavigation([options])\n\n\n**NOTE** `page.setDefaultNavigationTimeout` and `page.setDefaultTimeout` take priority over `browserContext.setDefaultNavigationTimeout`.","returnComment":"","required":true,"args":{"timeout":{"kind":"property","name":"timeout","type":{"name":"number"},"comment":"Maximum navigation time in milliseconds","returnComment":"","required":true}}},"setDefaultTimeout":{"kind":"method","name":"setDefaultTimeout","type":null,"comment":"This setting will change the default maximum time for all the methods accepting `timeout` option.\n\n**NOTE** `page.setDefaultNavigationTimeout`, `page.setDefaultTimeout` and `browserContext.setDefaultNavigationTimeout` take priority over `browserContext.setDefaultTimeout`.","returnComment":"","required":true,"args":{"timeout":{"kind":"property","name":"timeout","type":{"name":"number"},"comment":"Maximum time in milliseconds","returnComment":"","required":true}}},"setExtraHTTPHeaders":{"kind":"method","name":"setExtraHTTPHeaders","type":{"name":"Promise"},"comment":"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 page.setExtraHTTPHeaders(). If page overrides a particular header, page-specific header value will be used instead of the browser context header value.\n\n**NOTE** `browserContext.setExtraHTTPHeaders` does not guarantee the order of headers in the outgoing requests.","returnComment":"","required":true,"args":{"headers":{"kind":"property","name":"headers","type":{"name":"Object"},"comment":"An object containing additional HTTP headers to be sent with every request. All header values must be strings.","returnComment":"","required":true}}},"setGeolocation":{"kind":"method","name":"setGeolocation","type":{"name":"Promise"},"comment":"Sets the context's geolocation. Passing `null` or `undefined` emulates position unavailable.\n```js\nawait browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});\n```\n\n**NOTE** Consider using browserContext.grantPermissions to grant permissions for the browser context pages to read its geolocation.","returnComment":"","required":true,"args":{"geolocation":{"kind":"property","name":"geolocation","type":{"name":"null|Object","properties":{"latitude":{"kind":"property","name":"latitude","type":{"name":"number"},"comment":"Latitude between -90 and 90. **required**","returnComment":"","required":true},"longitude":{"kind":"property","name":"longitude","type":{"name":"number"},"comment":"Longitude between -180 and 180. **required**","returnComment":"","required":true},"accuracy":{"kind":"property","name":"accuracy","type":{"name":"number"},"comment":"Non-negative accuracy value. Defaults to `0`.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":true}}},"setHTTPCredentials":{"kind":"method","name":"setHTTPCredentials","type":{"name":"Promise"},"comment":"Provide credentials for HTTP authentication.\n\n**NOTE** Browsers may cache credentials after successful authentication. Passing different credentials or passing `null` to disable authentication will be unreliable. To remove or replace credentials, create a new browser context instead.","returnComment":"","required":true,"args":{"httpCredentials":{"kind":"property","name":"httpCredentials","type":{"name":"null|Object","properties":{"username":{"kind":"property","name":"username","type":{"name":"string"},"comment":"**required**","returnComment":"","required":true},"password":{"kind":"property","name":"password","type":{"name":"string"},"comment":"**required**","returnComment":"","required":true}}},"comment":"","returnComment":"","required":true}}},"setOffline":{"kind":"method","name":"setOffline","type":{"name":"Promise"},"comment":"","returnComment":"","required":true,"args":{"offline":{"kind":"property","name":"offline","type":{"name":"boolean"},"comment":"Whether to emulate network being offline for the browser context.","returnComment":"","required":true}}},"unroute":{"kind":"method","name":"unroute","type":{"name":"Promise"},"comment":"Removes a route created with browserContext.route(url, handler). When `handler` is not specified, removes all routes for the `url`.","returnComment":"","required":true,"args":{"url":{"kind":"property","name":"url","type":{"name":"string|RegExp|function(URL):boolean"},"comment":"A glob pattern, regex pattern or predicate receiving URL used to register a routing with browserContext.route(url, handler).","returnComment":"","required":true},"handler":{"kind":"property","name":"handler","type":{"name":"function(Route, Request)"},"comment":"Handler function used to register a routing with browserContext.route(url, handler).","returnComment":"","required":false}}},"waitForEvent":{"kind":"method","name":"waitForEvent","type":{"name":"Promise"},"comment":"Waits for event to fire and passes its value into the predicate function. Resolves when the predicate returns truthy value. Will throw an error if the context closes before the event\nis fired.\n```js\nconst context = await browser.newContext();\nawait context.grantPermissions(['geolocation']);\n```","returnComment":"Promise which resolves to the event data value.","required":true,"args":{"event":{"kind":"property","name":"event","type":{"name":"string"},"comment":"Event name, same one would pass into `browserContext.on(event)`.","returnComment":"","required":true},"optionsOrPredicate":{"kind":"property","name":"optionsOrPredicate","type":{"name":"Function|Object","properties":{"predicate":{"kind":"property","name":"predicate","type":{"name":"Function"},"comment":"receives the event data and resolves to truthy value when the waiting should resolve.","returnComment":"","required":false},"timeout":{"kind":"property","name":"timeout","type":{"name":"number"},"comment":"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).","returnComment":"","required":false}}},"comment":"Either a predicate that receives an event or an options object.","returnComment":"","required":false}}}}},"Page":{"name":"Page","extends":"EventEmitter","members":{"close":{"kind":"method","name":"close","type":{"name":"Promise"},"comment":"If `runBeforeUnload` is `false` the result will resolve only after the page has been closed.\nIf `runBeforeUnload` is `true` the method will **not** wait for the page to close.\nBy default, `page.close()` **does not** run beforeunload handlers.\n\n**NOTE** if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned\nand should be handled manually via page's 'dialog' event.","returnComment":"","required":true,"args":{"options":{"kind":"property","name":"options","type":{"name":"Object","properties":{"runBeforeUnload":{"kind":"property","name":"runBeforeUnload","type":{"name":"boolean"},"comment":"Defaults to `false`. Whether to run the\nbefore unload\npage handlers.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false}}},"console":{"kind":"event","name":"console","type":{"name":"ConsoleMessage"},"comment":"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.\nThe arguments passed into `console.log` appear as arguments on the event handler.\nAn example of handling `console` event:\n```js\npage.on('console', msg => {\n for (let i = 0; i < msg.args().length; ++i)\n console.log(`${i}: ${msg.args()[i]}`);\n});\npage.evaluate(() => console.log('hello', 5, {foo: 'bar'}));\n```","returnComment":"","required":true,"args":{}},"crash":{"kind":"event","name":"crash","type":null,"comment":"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.\nThe most common way to deal with crashes is to catch an exception:\n```js\ntry {\n // Crash might happen during a click.\n await page.click('button');\n // Or while waiting for an event.\n await page.waitForEvent('popup');\n} catch (e) {\n // When the page crashes, exception message contains 'crash'.\n}\n```\nHowever, when manually listening to events, it might be useful to avoid stalling when the page crashes. In this case, handling `crash` event helps:\n```js\nawait new Promise((resolve, reject) => {\n page.on('requestfinished', async request => {\n if (await someProcessing(request))\n resolve(request);\n });\n page.on('crash', error => reject(error));\n});\n```","returnComment":"","required":true,"args":{}},"dialog":{"kind":"event","name":"dialog","type":{"name":"Dialog"},"comment":"Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Playwright can respond to the dialog via Dialog's accept or dismiss methods.","returnComment":"","required":true,"args":{}},"domcontentloaded":{"kind":"event","name":"domcontentloaded","type":null,"comment":"Emitted when the JavaScript `DOMContentLoaded` event is dispatched.","returnComment":"","required":true,"args":{}},"download":{"kind":"event","name":"download","type":{"name":"Download"},"comment":"Emitted when attachment download started. User can access basic file operations on downloaded content via the passed Download instance.\n\n**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.","returnComment":"","required":true,"args":{}},"filechooser":{"kind":"event","name":"filechooser","type":{"name":"FileChooser"},"comment":"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` that can be uploaded after that.\n```js\npage.on('filechooser', async (fileChooser) => {\n await fileChooser.setFiles('/tmp/myfile.pdf');\n});\n```","returnComment":"","required":true,"args":{}},"frameattached":{"kind":"event","name":"frameattached","type":{"name":"Frame"},"comment":"Emitted when a frame is attached.","returnComment":"","required":true,"args":{}},"framedetached":{"kind":"event","name":"framedetached","type":{"name":"Frame"},"comment":"Emitted when a frame is detached.","returnComment":"","required":true,"args":{}},"framenavigated":{"kind":"event","name":"framenavigated","type":{"name":"Frame"},"comment":"Emitted when a frame is navigated to a new url.","returnComment":"","required":true,"args":{}},"load":{"kind":"event","name":"load","type":null,"comment":"Emitted when the JavaScript `load` event is dispatched.","returnComment":"","required":true,"args":{}},"pageerror":{"kind":"event","name":"pageerror","type":{"name":"Error"},"comment":"Emitted when an uncaught exception happens within the page.","returnComment":"","required":true,"args":{}},"popup":{"kind":"event","name":"popup","type":{"name":"Page"},"comment":"Emitted when the page opens a new tab or window. This event is emitted in addition to the `browserContext.on('page')`, but only for popups relevant to this page.\nThe 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.\n```js\nconst [popup] = await Promise.all([\n page.waitForEvent('popup'),\n page.evaluate(() => window.open('https://example.com')),\n]);\nconsole.log(await popup.evaluate('location.href'));\n```\n\n**NOTE** Use `page.waitForLoadState([state[, options]])` to wait until the page gets to a particular state (you should not need it in most cases).","returnComment":"","required":true,"args":{}},"request":{"kind":"event","name":"request","type":{"name":"Request"},"comment":"Emitted when a page issues a request. The request object is read-only.\nIn order to intercept and mutate requests, see `page.route()` or `browserContext.route()`.","returnComment":"","required":true,"args":{}},"requestfailed":{"kind":"event","name":"requestfailed","type":{"name":"Request"},"comment":"Emitted when a request fails, for example by timing out.\n\n**NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with `'requestfinished'` event and not with `'requestfailed'`.","returnComment":"","required":true,"args":{}},"requestfinished":{"kind":"event","name":"requestfinished","type":{"name":"Request"},"comment":"Emitted when a request finishes successfully after downloading the response body. For a successful response, the sequence of events is `request`, `response` and `requestfinished`.","returnComment":"","required":true,"args":{}},"response":{"kind":"event","name":"response","type":{"name":"Response"},"comment":"Emitted when response status and headers are received for a request. For a successful response, the sequence of events is `request`, `response` and `requestfinished`.","returnComment":"","required":true,"args":{}},"worker":{"kind":"event","name":"worker","type":{"name":"Worker"},"comment":"Emitted when a dedicated WebWorker is spawned by the page.","returnComment":"","required":true,"args":{}},"$":{"kind":"method","name":"$","type":{"name":"Promise"},"comment":"The method finds an element matching the specified selector within the page. If no elements match the selector, the return value resolves to `null`.\nShortcut for page.mainFrame().$(selector).","returnComment":"","required":true,"args":{"selector":{"kind":"property","name":"selector","type":{"name":"string"},"comment":"A selector to query page for. See working with selectors for more details.","returnComment":"","required":true}}},"$$":{"kind":"method","name":"$$","type":{"name":"Promise>"},"comment":"The method finds all elements matching the specified selector within the page. If no elements match the selector, the return value resolves to `[]`.\nShortcut for page.mainFrame().$$(selector).","returnComment":"","required":true,"args":{"selector":{"kind":"property","name":"selector","type":{"name":"string"},"comment":"A selector to query page for. See working with selectors for more details.","returnComment":"","required":true}}},"$eval":{"kind":"method","name":"$eval","type":{"name":"Promise"},"comment":"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.\nIf `pageFunction` returns a Promise, then `page.$eval` would wait for the promise to resolve and return its value.\nExamples:\n```js\nconst searchValue = await page.$eval('#search', el => el.value);\nconst preloadHref = await page.$eval('link[rel=preload]', el => el.href);\nconst html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');\n```\nShortcut for page.mainFrame().$eval(selector, pageFunction).","returnComment":"Promise which resolves to the return value of `pageFunction`","required":true,"args":{"selector":{"kind":"property","name":"selector","type":{"name":"string"},"comment":"A selector to query page for. See working with selectors for more details.","returnComment":"","required":true},"pageFunction":{"kind":"property","name":"pageFunction","type":{"name":"function(Element)"},"comment":"Function to be evaluated in browser context","returnComment":"","required":true},"arg":{"kind":"property","name":"arg","type":{"name":"EvaluationArgument"},"comment":"Optional argument to pass to `pageFunction`","returnComment":"","required":false}}},"$$eval":{"kind":"method","name":"$$eval","type":{"name":"Promise"},"comment":"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`.\nIf `pageFunction` returns a Promise, then `page.$$eval` would wait for the promise to resolve and return its value.\nExamples:\n```js\nconst divsCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);\n```","returnComment":"Promise which resolves to the return value of `pageFunction`","required":true,"args":{"selector":{"kind":"property","name":"selector","type":{"name":"string"},"comment":"A selector to query page for. See working with selectors for more details.","returnComment":"","required":true},"pageFunction":{"kind":"property","name":"pageFunction","type":{"name":"function(Array)"},"comment":"Function to be evaluated in browser context","returnComment":"","required":true},"arg":{"kind":"property","name":"arg","type":{"name":"EvaluationArgument"},"comment":"Optional argument to pass to `pageFunction`","returnComment":"","required":false}}},"accessibility":{"kind":"property","name":"accessibility","type":{"name":"Accessibility"},"comment":"","returnComment":"","required":true,"args":{}},"addInitScript":{"kind":"method","name":"addInitScript","type":{"name":"Promise"},"comment":"Adds a script which would be evaluated in one of the following scenarios:\n\nWhenever the page is navigated.\nWhenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.\n\nThe 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`.\nAn example of overriding `Math.random` before the page loads:\n```js\n// preload.js\nMath.random = () => 42;\n\n// In your playwright script, assuming the preload.js file is in same folder\nconst preloadFile = fs.readFileSync('./preload.js', 'utf8');\nawait page.addInitScript(preloadFile);\n```\n\n**NOTE** The order of evaluation of multiple scripts installed via browserContext.addInitScript(script[, arg]) and page.addInitScript(script[, arg]) is not defined.","returnComment":"","required":true,"args":{"script":{"kind":"property","name":"script","type":{"name":"function|string|Object","properties":{"path":{"kind":"property","name":"path","type":{"name":"string"},"comment":"Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to current working directory.","returnComment":"","required":false},"content":{"kind":"property","name":"content","type":{"name":"string"},"comment":"Raw script content.","returnComment":"","required":false}}},"comment":"Script to be evaluated in the page.","returnComment":"","required":true},"arg":{"kind":"property","name":"arg","type":{"name":"Serializable"},"comment":"Optional argument to pass to `script` (only supported when passing a function).","returnComment":"","required":false}}},"addScriptTag":{"kind":"method","name":"addScriptTag","type":{"name":"Promise"},"comment":"Adds a `\n \n
\n `);\n await page.click('button');\n})();\n```\nAn example of passing an element handle:\n```js\nawait page.exposeBinding('clicked', async (source, element) => {\n console.log(await element.textContent());\n}, { handle: true });\nawait page.setContent(`\n \n
Click me
\n
Or click me
\n`);\n```","returnComment":"","required":true,"args":{"name":{"kind":"property","name":"name","type":{"name":"string"},"comment":"Name of the function on the window object.","returnComment":"","required":true},"playwrightBinding":{"kind":"property","name":"playwrightBinding","type":{"name":"function"},"comment":"Callback function that will be called in the Playwright's context.","returnComment":"","required":true},"options":{"kind":"property","name":"options","type":{"name":"Object","properties":{"handle":{"kind":"property","name":"handle","type":{"name":"boolean"},"comment":"Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is supported. When passing by value, multiple arguments are supported.","returnComment":"","required":false}}},"comment":"","returnComment":"","required":false}}},"exposeFunction":{"kind":"method","name":"exposeFunction","type":{"name":"Promise"},"comment":"The method adds a function called `name` on the `window` object of every frame in the page.\nWhen called, the function executes `playwrightFunction` in Node.js and returns a Promise which resolves to the return value of `playwrightFunction`.\nIf the `playwrightFunction` returns a Promise, it will be awaited.\nSee browserContext.exposeFunction(name, playwrightFunction) for context-wide exposed function.\n\n**NOTE** Functions installed via `page.exposeFunction` survive navigations.\n\nAn example of adding an `md5` function to the page:\n```js\nconst { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.\nconst crypto = require('crypto');\n\n(async () => {\n const browser = await webkit.launch({ headless: false });\n const page = await browser.newPage();\n await page.exposeFunction('md5', text => crypto.createHash('md5').update(text).digest('hex'));\n await page.setContent(`\n \n \n
\n `);\n await page.click('button');\n})();\n```\nAn example of adding a `window.readfile` function to the page:\n```js\nconst { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.\nconst fs = require('fs');\n\n(async () => {\n const browser = await chromium.launch();\n const page = await browser.newPage();\n page.on('console', msg => console.log(msg.text()));\n await page.exposeFunction('readfile', async filePath => {\n return new Promise((resolve, reject) => {\n fs.readFile(filePath, 'utf8', (err, text) => {\n if (err)\n reject(err);\n else\n resolve(text);\n });\n });\n });\n await page.evaluate(async () => {\n // use window.readfile to read contents of a file\n const content = await window.readfile('/etc/hosts');\n console.log(content);\n });\n await browser.close();\n})();\n```","returnComment":"","required":true,"args":{"name":{"kind":"property","name":"name","type":{"name":"string"},"comment":"Name of the function on the window object","returnComment":"","required":true},"playwrightFunction":{"kind":"property","name":"playwrightFunction","type":{"name":"function"},"comment":"Callback function which will be called in Playwright's context.","returnComment":"","required":true}}},"fill":{"kind":"method","name":"fill","type":{"name":"Promise"},"comment":"This method waits for an element matching `selector`, waits for actionability checks, focuses the element, fills it and triggers an `input` event after filling.\nIf the element matching `selector` is not an ``, `