feat: experimental WebDriver BiDi support with Firefox (#11412)

Co-authored-by: Jecelyn Yeen <5917927+jecfish@users.noreply.github.com>
This commit is contained in:
Alex Rudenko 2023-11-28 13:07:53 +01:00 committed by GitHub
parent 6a944bf8aa
commit 8aba033dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 269 additions and 485 deletions

View File

@ -198,6 +198,7 @@ sidebar_label: API
| [Predicate](./puppeteer.predicate.md) | |
| [Product](./puppeteer.product.md) | Supported products. |
| [ProtocolLifeCycleEvent](./puppeteer.protocollifecycleevent.md) | |
| [ProtocolType](./puppeteer.protocoltype.md) | |
| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) | |
| [PuppeteerNodeLaunchOptions](./puppeteer.puppeteernodelaunchoptions.md) | Utility type exposed to enable users to define options that can be passed to <code>puppeteer.launch</code> without having to list the set of all types. |
| [Quad](./puppeteer.quad.md) | |

View File

@ -18,6 +18,7 @@ export interface BrowserConnectOptions
| ----------------- | --------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------- | --------------------------- |
| defaultViewport | <code>optional</code> | [Viewport](./puppeteer.viewport.md) \| null | Sets the viewport for each page. | '{width: 800, height: 600}' |
| ignoreHTTPSErrors | <code>optional</code> | boolean | Whether to ignore HTTPS errors during navigation. | <code>false</code> |
| protocol | <code>optional</code> | [ProtocolType](./puppeteer.protocoltype.md) | | 'cdp' |
| protocolTimeout | <code>optional</code> | number | Timeout setting for individual protocol (CDP) calls. | <code>180_000</code> |
| slowMo | <code>optional</code> | number | Slows down Puppeteer operations by the specified amount of milliseconds to aid debugging. | |
| targetFilter | <code>optional</code> | [TargetFilterCallback](./puppeteer.targetfiltercallback.md) | Callback to decide if Puppeteer should connect to a given target or not. | |

View File

@ -28,6 +28,8 @@ Promise&lt;void&gt;
## Remarks
This method is a shortcut for calling two methods: [Page.setUserAgent()](./puppeteer.page.setuseragent.md) and [Page.setViewport()](./puppeteer.page.setviewport.md).
This method will resize the page. A lot of websites don't expect phones to change size, so you should emulate before navigating to the page.
## Example

View File

@ -32,8 +32,6 @@ class Page {
Promise&lt;void&gt;
## Remarks
## Example
```ts

View File

@ -0,0 +1,11 @@
---
sidebar_label: ProtocolType
---
# ProtocolType type
#### Signature:
```typescript
export type ProtocolType = 'cdp' | 'webDriverBiDi';
```

View File

@ -27,6 +27,16 @@ support to browsers such as Safari. This effort includes exploration of a
standard for executing cross-browser commands (instead of relying on the
non-standard DevTools Protocol used by Chrome).
Update 2023-11-17: Puppeteer has experimental support for the new
[WebDriverBiDi](https://w3c.github.io/webdriver-bidi/) protocol that can be used
to automate Firefox. The WebDriver BiDi implementation in Firefox will replace
the current CDP implementation in Firefox in the future. See
https://pptr.dev/webdriver-bidi for more details.
## Q: Does Puppeteer support WebDriver BiDi?
Puppeteer has experimental support for WebDriver BiDi. See https://pptr.dev/webdriver-bidi.
## Q: What are Puppeteers goals and principles?
The goals of the project are:

189
docs/webdriver-bidi.md Normal file
View File

@ -0,0 +1,189 @@
# Experimental WebDriver BiDi Support
[WebDriver BiDi](https://w3c.github.io/webdriver-bidi/) is a new cross-browser
automation protocol that adds browser-driven events to WebDriver. Here are the
resources if you want to learn more about WebDriver BiDi:
- [WebDriver BiDi - The future of cross-browser automation](https://developer.chrome.com/articles/webdriver-bidi/)
- [WebDriver BiDi: 2023 status update](https://developer.chrome.com/blog/webdriver-bidi-2023/)
## Automate with Chrome and Firefox
Firefox support has almost reaching feature parity with the previous CDP-based
implementation. To see which features are fully supported with WebDriver BiDi we
used the [Puppeteer test suite](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/). Currently,
we still have fewer than
[60](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json)
tests that are failing with Firefox and WebDriver BiDi compared to the previous
CDP implementation in Firefox but we also have more than
[82](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json)
new tests that work with WebDriver BiDi and that didn't work with CDP.
For Chrome, around 68% of the tests are currently passing with WebDriver BiDi so
the CDP-based implementation remains more powerful. Some of the Puppeteer
functionality is relying on CDP even with WebDriver BiDi enabled. Therefore, the
test pass rate is currently higher than that one of Firefox.
Example of launching Firefox with WebDriver BiDi:
```ts
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({
product: 'firefox',
protocol: 'webDriverBiDi',
});
const page = await browser.newPage();
...
await browser.close();
```
Example of launching Chrome with WebDriver BiDi:
```ts
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({
product: 'chrome',
protocol: 'webDriverBiDi',
});
const page = await browser.newPage();
...
await browser.close();
```
## Puppeteer features supported over WebDriver BiDi
- Browser and page automation
- Browser.close
- Frame.goto() (except `referer` and `referrerPolicy`)
- Page.bringToFront
- Page.goto (except `referer` and `referrerPolicy`)
- Page.reload (except for `ignoreCache` parameter)
- Page.setViewport (`width`, `height`, `deviceScaleFactor` only)
- Puppeteer.launch
- [Script evaluation](https://pptr.dev/guides/evaluate-javascript):
- JSHandle.evaluate
- JSHandle.evaluateHandle
- Page.evaluate
- Page.exposeFunction
- [Selectors](https://pptr.dev/guides/query-selectors) and [locators](https://pptr.dev/guides/locators) except for ARIA:
- Page.$ (ARIA selectors supported in Chrome)
- Page.$$ (ARIA selectors supported in Chrome)
- Page.$$eval (ARIA selectors supported in Chrome)
- Page.$eval (ARIA selectors supported in Chrome)
- Page.waitForSelector (ARIA selectors supported in Chrome)
- Input
- ElementHandle.click
- Keyboard.down
- Keyboard.press
- Keyboard.sendCharacter
- Keyboard.type
- Keyboard.up
- Mouse events (except for dedicated drag'n'drop API methods)
- Page.tap
- TouchScreen.\*
- JavaScript dialog interception
- page.on('dialog')
- Dialog.\*
- Screenshots (not all parameters are supported)
- Page.screenshot (supported parameters `clip`, `encoding`, `fullPage`)
- PDF generation (not all parameters are supported)
- Page.pdf (only `format`, `height`, `landscape`, `margin`, `pageRanges`, `printBackground`, `scale`, `width` are supported)
- Page.createPDFStream (only `format`, `height`, `landscape`, `margin`, `pageRanges`, `printBackground`, `scale`, `width` are supported)
## Puppeteer features not yet supported over WebDriver BiDi
- [Request interception](https://pptr.dev/guides/request-interception)
- HTTPRequest.abort()
- HTTPRequest.abortErrorReason()
- HTTPRequest.client()
- HTTPRequest.continue()
- HTTPRequest.continueRequestOverrides()
- HTTPRequest.failure()
- HTTPRequest.finalizeInterceptions()
- HTTPRequest.interceptResolutionState()
- HTTPRequest.isInterceptResolutionHandled()
- HTTPRequest.respond()
- HTTPRequest.responseForRequest()
- Page.setRequestInterception()
- Permissions
- BrowserContext.clearPermissionOverrides()
- BrowserContext.overridePermissions()
- Various emulations (most are supported with Chrome)
- Page.emulate() (supported only in Chrome)
- Page.emulateCPUThrottling() (supported only in Chrome)
- Page.emulateIdleState() (supported only in Chrome)
- Page.emulateMediaFeatures() (supported only in Chrome)
- Page.emulateMediaType() (supported only in Chrome)
- Page.emulateTimezone() (supported only in Chrome)
- Page.emulateVisionDeficiency() (supported only in Chrome)
- Page.setBypassCSP() (supported only in Chrome)
- Page.setCacheEnabled() (supported only in Chrome)
- Page.setGeolocation() (supported only in Chrome)
- Page.setJavaScriptEnabled() (supported only in Chrome)
- CDP-specific features
- Page.createCDPSession() (supported only in Chrome)
- Tracing (supported only in Chrome)
- Coverage (supported only in Chrome)
- Accessibility (supported only in Chrome)
- Other methods:
- Browser.userAgent()
- ElementHandle.uploadFile()
- Frame.isOOPFrame()
- Frame.waitForDevicePrompt()
- HTTPResponse.buffer()
- HTTPResponse.fromServiceWorker()
- HTTPResponse.securityDetails()
- Input.drag()
- Input.dragAndDrop()
- Input.dragOver()
- Input.drop()
- Page.authenticate()
- Page.cookies()
- Page.deleteCookie()
- Page.emulateNetworkConditions()
- Page.goBack()
- Page.goForward()
- Page.isDragInterceptionEnabled()
- Page.isJavaScriptEnabled() (supported only in Chrome)
- Page.isServiceWorkerBypassed()
- Page.metrics()
- Page.queryObjects() (supported only in Chrome)
- Page.screencast() (supported only in Chrome)
- Page.setBypassServiceWorker()
- Page.setCookie()
- Page.setDragInterception()
- Page.setExtraHTTPHeaders()
- Page.setOfflineMode()
- Page.setUserAgent()
- Page.waitForDevicePrompt()
- Page.waitForFileChooser()
- Page.workers()
- PageEvent.popup
- PageEvent.WorkerCreated
- PageEvent.WorkerDestroyed
- Target.opener()

View File

@ -401,10 +401,6 @@ export abstract class Browser extends EventEmitter<BrowserEvents> {
* {@link Page | Pages} can override the user agent with
* {@link Page.setUserAgent}.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract userAgent(): Promise<string>;

View File

@ -164,11 +164,6 @@ export abstract class BrowserContext extends EventEmitter<BrowserContextEvents>
* "https://example.com".
* @param permissions - An array of permissions to grant. All permissions that
* are not listed here will be automatically denied.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract overridePermissions(
origin: string,
@ -188,11 +183,6 @@ export abstract class BrowserContext extends EventEmitter<BrowserContextEvents>
* // do stuff ..
* context.clearPermissionOverrides();
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract clearPermissionOverrides(): Promise<void>;

View File

@ -962,11 +962,6 @@ export abstract class ElementHandle<
* {@link https://nodejs.org/api/process.html#process_process_cwd | current working directory}.
* For locals script connecting to remote chrome environments, paths must be
* absolute.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract uploadFile(
this: ElementHandle<HTMLInputElement>,

View File

@ -311,11 +311,6 @@ export abstract class Frame extends EventEmitter<FrameEvents> {
/**
* Is `true` if the frame is an out-of-process (OOP) frame. Otherwise,
* `false`.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract isOOPFrame(): boolean;
@ -352,14 +347,6 @@ export abstract class Frame extends EventEmitter<FrameEvents> {
* returned by the remote server, including 404 "Not Found" and 500 "Internal
* Server Error". The status code for such responses can be retrieved by
* calling {@link HTTPResponse.status}.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* - `referer` not supported
* - `referrerPolicy` not supported
*/
abstract goto(
url: string,
@ -1209,11 +1196,6 @@ export abstract class Frame extends EventEmitter<FrameEvents> {
* );
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* @internal
*/
abstract waitForDevicePrompt(

View File

@ -130,11 +130,6 @@ export abstract class HTTPRequest {
* Warning! Using this client can break Puppeteer. Use with caution.
*
* @experimental
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract get client(): CDPSession;
@ -152,32 +147,17 @@ export abstract class HTTPRequest {
* The `ContinueRequestOverrides` that will be used
* if the interception is allowed to continue (ie, `abort()` and
* `respond()` aren't called).
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract continueRequestOverrides(): ContinueRequestOverrides;
/**
* The `ResponseForRequest` that gets used if the
* interception is allowed to respond (ie, `abort()` is not called).
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract responseForRequest(): Partial<ResponseForRequest> | null;
/**
* The most recent reason for aborting the request
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract abortErrorReason(): Protocol.Network.ErrorReason | null;
@ -191,22 +171,12 @@ export abstract class HTTPRequest {
*
* InterceptResolutionAction is one of: `abort`, `respond`, `continue`,
* `disabled`, `none`, or `already-handled`.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract interceptResolutionState(): InterceptResolutionState;
/**
* Is `true` if the intercept resolution has already been handled,
* `false` otherwise.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract isInterceptResolutionHandled(): boolean;
@ -223,11 +193,6 @@ export abstract class HTTPRequest {
/**
* Awaits pending interception handlers and then decides how to fulfill
* the request interception.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract finalizeInterceptions(): Promise<void>;
@ -323,24 +288,12 @@ export abstract class HTTPRequest {
* return an object with `errorText` containing a human-readable error
* message, e.g. `net::ERR_FAILED`. It is not guaranteed that there will be
* failure text if the request fails.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract failure(): {errorText: string} | null;
/**
* Continues request with optional request overrides.
*
* @remarks
*
* To use this, request
* interception should be enabled with {@link Page.setRequestInterception}.
*
* Exception is immediately thrown if the request interception is not enabled.
*
* @example
*
* ```ts
@ -356,14 +309,15 @@ export abstract class HTTPRequest {
* ```
*
* @param overrides - optional overrides to apply to the request.
* @param priority - If provided, intercept is resolved using
* cooperative handling rules. Otherwise, intercept is resolved
* immediately.
* @param priority - If provided, intercept is resolved using cooperative
* handling rules. Otherwise, intercept is resolved immediately.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
* @remarks
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
* To use this, request interception should be enabled with
* {@link Page.setRequestInterception}.
*
* Exception is immediately thrown if the request interception is not enabled.
*/
abstract continue(
overrides?: ContinueRequestOverrides,
@ -373,13 +327,6 @@ export abstract class HTTPRequest {
/**
* Fulfills a request with the given response.
*
* @remarks
*
* To use this, request
* interception should be enabled with {@link Page.setRequestInterception}.
*
* Exception is immediately thrown if the request interception is not enabled.
*
* @example
* An example of fulfilling all requests with 404 responses:
*
@ -402,10 +349,12 @@ export abstract class HTTPRequest {
* cooperative handling rules. Otherwise, intercept is resolved
* immediately.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
* @remarks
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
* To use this, request
* interception should be enabled with {@link Page.setRequestInterception}.
*
* Exception is immediately thrown if the request interception is not enabled.
*/
abstract respond(
response: Partial<ResponseForRequest>,
@ -415,20 +364,16 @@ export abstract class HTTPRequest {
/**
* Aborts a request.
*
* @remarks
* To use this, request interception should be enabled with
* {@link Page.setRequestInterception}. If it is not enabled, this method will
* throw an exception immediately.
*
* @param errorCode - optional error code to provide.
* @param priority - If provided, intercept is resolved using
* cooperative handling rules. Otherwise, intercept is resolved
* immediately.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
* @remarks
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
* To use this, request interception should be enabled with
* {@link Page.setRequestInterception}. If it is not enabled, this method will
* throw an exception immediately.
*/
abstract abort(errorCode?: ErrorCode, priority?: number): Promise<void>;
}

View File

@ -81,11 +81,6 @@ export abstract class HTTPResponse {
/**
* {@link SecurityDetails} if the response was received over the
* secure connection, or `null` otherwise.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract securityDetails(): SecurityDetails | null;
@ -96,11 +91,6 @@ export abstract class HTTPResponse {
/**
* Promise which resolves to a buffer with response body.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract buffer(): Promise<Buffer>;
@ -138,11 +128,6 @@ export abstract class HTTPResponse {
/**
* True if the response was served by a service worker.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract fromServiceWorker(): boolean;

View File

@ -435,11 +435,6 @@ export abstract class Mouse {
* Dispatches a `drag` event.
* @param start - starting point for drag
* @param target - point to drag to
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract drag(start: Point, target: Point): Promise<Protocol.Input.DragData>;
@ -447,11 +442,6 @@ export abstract class Mouse {
* Dispatches a `dragenter` event.
* @param target - point for emitting `dragenter` event
* @param data - drag data containing items and operations mask
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract dragEnter(
target: Point,
@ -462,11 +452,6 @@ export abstract class Mouse {
* Dispatches a `dragover` event.
* @param target - point for emitting `dragover` event
* @param data - drag data containing items and operations mask
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract dragOver(
target: Point,
@ -477,11 +462,6 @@ export abstract class Mouse {
* Performs a dragenter, dragover, and drop in sequence.
* @param target - point to drop on
* @param data - drag data containing items and operations mask
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract drop(target: Point, data: Protocol.Input.DragData): Promise<void>;
@ -492,11 +472,6 @@ export abstract class Mouse {
* @param options - An object of options. Accepts delay which,
* if specified, is the time to wait between `dragover` and `drop` in milliseconds.
* Defaults to 0.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract dragAndDrop(
start: Point,

View File

@ -420,11 +420,6 @@ export const enum PageEvent {
* page.evaluate(() => window.open('https://example.com')),
* ]);
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
Popup = 'popup',
/**
@ -468,22 +463,12 @@ export const enum PageEvent {
* Emitted when a dedicated
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
* is spawned by the page.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
WorkerCreated = 'workercreated',
/**
* Emitted when a dedicated
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
* is destroyed by the page.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
WorkerDestroyed = 'workerdestroyed',
}
@ -624,11 +609,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* `true` if the service worker are being bypassed, `false` otherwise.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract isServiceWorkerBypassed(): boolean;
@ -638,23 +618,11 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @deprecated We no longer support intercepting drag payloads. Use the new
* drag APIs found on {@link ElementHandle} to drag (or just use the
* {@link Page.mouse}).
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract isDragInterceptionEnabled(): boolean;
/**
* `true` if the page has JavaScript enabled, `false` otherwise.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract isJavaScriptEnabled(): boolean;
@ -740,11 +708,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* ]);
* await fileChooser.accept(['/tmp/myfile.pdf']);
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract waitForFileChooser(
options?: WaitTimeoutOptions
@ -762,13 +725,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* ```ts
* await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract setGeolocation(options: GeolocationOptions): Promise<void>;
@ -797,13 +753,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* Creates a Chrome Devtools Protocol session attached to the page.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract createCDPSession(): Promise<CDPSession>;
@ -844,11 +793,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @remarks
* This does not contain ServiceWorkers
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract workers(): WebWorker[];
@ -887,11 +831,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* ```
*
* @param value - Whether to enable request interception.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract setRequestInterception(value: boolean): Promise<void>;
@ -899,11 +838,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* Toggles ignoring of service worker for each request.
*
* @param bypass - Whether to bypass service worker and load from network.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract setBypassServiceWorker(bypass: boolean): Promise<void>;
@ -913,11 +847,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @deprecated We no longer support intercepting drag payloads. Use the new
* drag APIs found on {@link ElementHandle} to drag (or just use the
* {@link Page.mouse}).
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract setDragInterception(enabled: boolean): Promise<void>;
@ -927,11 +856,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* It does not change the parameters used in {@link Page.emulateNetworkConditions}
*
* @param enabled - When `true`, enables offline mode for the page.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract setOfflineMode(enabled: boolean): Promise<void>;
@ -961,11 +885,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @param networkConditions - Passing `null` disables network condition
* emulation.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract emulateNetworkConditions(
networkConditions: NetworkConditions | null
@ -1049,15 +968,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @param selector - A `selector` to query page for
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
* to query page for.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* - ARIA selector not supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
async $<Selector extends string>(
selector: Selector
@ -1068,18 +978,12 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* The method runs `document.querySelectorAll` within the page. If no elements
* match the selector, the return value resolves to `[]`.
* @remarks
* Shortcut for {@link Frame.$$ | Page.mainFrame().$$(selector) }.
*
* @param selector - A `selector` to query page for
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
* @remarks
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* - ARIA selector not supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
* Shortcut for {@link Frame.$$ | Page.mainFrame().$$(selector) }.
*/
async $$<Selector extends string>(
selector: Selector
@ -1180,13 +1084,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @param prototypeHandle - a handle to the object prototype.
* @returns Promise which resolves to a handle to an array of objects with
* this prototype.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract queryObjects<Prototype>(
prototypeHandle: JSHandle<Prototype>
@ -1253,15 +1150,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @returns The result of calling `pageFunction`. If it returns an element it
* is wrapped in an {@link ElementHandle}, else the raw value itself is
* returned.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* - ARIA selector not supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
async $eval<
Selector extends string,
@ -1340,15 +1228,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @returns The result of calling `pageFunction`. If it returns an element it
* is wrapped in an {@link ElementHandle}, else the raw value itself is
* returned.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* - ARIA selector not supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
async $$eval<
Selector extends string,
@ -1383,20 +1262,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* If no URLs are specified, this method returns cookies for the current page
* URL. If URLs are specified, only cookies for those URLs are returned.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract cookies(...urls: string[]): Promise<Protocol.Network.Cookie[]>;
/**
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract deleteCookie(
...cookies: Protocol.Network.DeleteCookiesRequest[]
): Promise<void>;
@ -1407,11 +1275,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* ```ts
* await page.setCookie(cookieObject1, cookieObject2);
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract setCookie(...cookies: Protocol.Network.CookieParam[]): Promise<void>;
@ -1540,11 +1403,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @remarks
* To disable authentication, pass `null`.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract authenticate(credentials: Credentials): Promise<void>;
@ -1567,11 +1425,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @param headers - An object containing additional HTTP headers to be sent
* with every request. All header values must be strings.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
@ -1580,11 +1433,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @param userAgentData - Specific user agent client hint data to use in this
* page
* @returns Promise which resolves when the user agent is set.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract setUserAgent(
userAgent: string,
@ -1626,18 +1474,15 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @remarks
* All timestamps are in monotonic time: monotonically increasing time
* in seconds since an arbitrary point in the past.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract metrics(): Promise<Metrics>;
/**
* The page's URL.
* @remarks Shortcut for
* {@link Frame.url | page.mainFrame().url()}.
*
* @remarks
*
* Shortcut for {@link Frame.url | page.mainFrame().url()}.
*/
url(): string {
return this.mainFrame().url();
@ -1655,7 +1500,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @param html - HTML markup to assign to the page.
* @param options - Parameters that has some properties.
*
* @remarks
*
* The parameter `options` might have the following options.
*
* - `timeout` : Maximum time in milliseconds for resources to load, defaults
@ -1684,6 +1531,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* Navigates the page to the given `url`.
*
* @remarks
*
* Navigation to `about:blank` or navigation to the same URL with a different
* hash will succeed and return `null`.
*
@ -1744,6 +1592,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* ```
*
* @remarks
*
* Usage of the
* {@link https://developer.mozilla.org/en-US/docs/Web/API/History_API | History API}
* to change the URL is considered a navigation.
@ -1934,11 +1783,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* more than 0 network connections for at least `500` ms.<br/>
* - `networkidle2` : consider navigation to be finished when there are no
* more than 2 network connections for at least `500` ms.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
@ -1967,11 +1811,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* more than 0 network connections for at least `500` ms.<br/>
* - `networkidle2` : consider navigation to be finished when there are no
* more than 2 network connections for at least `500` ms.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
@ -1990,7 +1829,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* This method is a shortcut for calling two methods:
* {@link Page.setUserAgent} and {@link Page.setViewport}.
*
* @remarks
* This method will resize the page. A lot of websites don't expect phones to
* change size, so you should emulate before navigating to the page.
*
@ -2009,11 +1847,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* await browser.close();
* })();
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
async emulate(device: Device): Promise<void> {
await Promise.all([
@ -2027,13 +1860,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @remarks
* NOTE: changing this value won't affect scripts that have already been run.
* It will take full effect on the next navigation.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract setJavaScriptEnabled(enabled: boolean): Promise<void>;
@ -2044,13 +1870,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* NOTE: CSP bypassing happens at the moment of CSP initialization rather than
* evaluation. Usually, this means that `page.setBypassCSP` should be called
* before navigating to the domain.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract setBypassCSP(enabled: boolean): Promise<void>;
@ -2078,26 +1897,12 @@ export abstract class Page extends EventEmitter<PageEvents> {
* await page.evaluate(() => matchMedia('print').matches);
* // → false
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract emulateMediaType(type?: string): Promise<void>;
/**
* Enables CPU throttling to emulate slow CPUs.
* @param factor - slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract emulateCPUThrottling(factor: number | null): Promise<void>;
@ -2161,13 +1966,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* await page.evaluate(() => matchMedia('(color-gamut: rec2020)').matches);
* // → false
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
@ -2176,13 +1974,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* {@link https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt | ICUs metaZones.txt}
* for a list of supported timezone IDs. Passing
* `null` disables timezone emulation.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract emulateTimezone(timezoneId?: string): Promise<void>;
@ -2204,13 +1995,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* ```
*
* @param overrides - Mock idle state. If not set, clears idle overrides
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract emulateIdleState(overrides?: {
isUserActive: boolean;
@ -2244,13 +2028,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* ```
*
* @param type - the type of deficiency to simulate, or `'none'` to reset.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract emulateVisionDeficiency(
type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']
@ -2279,15 +2056,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @remarks
* NOTE: in certain cases, setting viewport will reload the page in order to
* set the isMobile or hasTouch properties.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* #TODO: List unsupported?
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract setViewport(viewport: Viewport): Promise<void>;
@ -2416,13 +2184,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* default, caching is enabled.
* @param enabled - sets the `enabled` state of cache
* @defaultValue `true`
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract setCacheEnabled(enabled?: boolean): Promise<void>;
@ -2445,13 +2206,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* Captures a screencast of this {@link Page | page}.
*
* @remarks
*
* All recordings will be {@link https://www.webmproject.org/ | WebM} format using
* the {@link https://www.webmproject.org/vp9/ | VP9} video codec. The FPS is 30.
*
* You must have {@link https://ffmpeg.org/ | ffmpeg} installed on your system.
*
* @example
* Recording a {@link Page | page}:
*
@ -2482,12 +2236,12 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @experimental
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
* @remarks
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
* All recordings will be {@link https://www.webmproject.org/ | WebM} format using
* the {@link https://www.webmproject.org/vp9/ | VP9} video codec. The FPS is 30.
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
* You must have {@link https://ffmpeg.org/ | ffmpeg} installed on your system.
*/
async screencast(
options: Readonly<ScreencastOptions> = {}
@ -2629,15 +2383,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* Captures a screenshot of this {@link Page | page}.
*
* @param options - Configures screenshot behavior.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* #TODO: List unsupported?
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
async screenshot(
options: Readonly<ScreenshotOptions> & {encoding: 'base64'}
@ -2789,6 +2534,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* Generates a PDF of the page with the `print` CSS media type.
*
* @param options - options for generating the PDF.
*
* @remarks
*
* To generate a PDF with the `screen` media type, call
@ -2799,17 +2547,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* Use the
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust | `-webkit-print-color-adjust`}
* property to force rendering of exact colors.
*
* @param options - options for generating the PDF.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* #TODO: List unsupported?
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*/
abstract createPDFStream(options?: PDFOptions): Promise<Readable>;
@ -2822,6 +2559,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* The page's title
*
* @remarks
*
* Shortcut for {@link Frame.title | page.mainFrame().title()}.
*/
async title(): Promise<string> {
@ -2846,7 +2584,10 @@ export abstract class Page extends EventEmitter<PageEvents> {
* needed, and then uses {@link Page | Page.mouse} to click in the center of the
* element. If there's no element matching `selector`, the method throws an
* error.
* @remarks Bear in mind that if `click()` triggers a navigation event and
*
* @remarks
*
* Bear in mind that if `click()` triggers a navigation event and
* there's a separate `page.waitForNavigation()` promise to be resolved, you
* may end up with a race condition that yields unexpected results. The
* correct pattern for click and wait for navigation is the following:
@ -2880,7 +2621,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @returns Promise which resolves when the element matching selector is
* successfully focused. The promise will be rejected if there is no element
* matching selector.
*
* @remarks
*
* Shortcut for {@link Frame.focus | page.mainFrame().focus(selector)}.
*/
focus(selector: string): Promise<void> {
@ -2899,7 +2642,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @returns Promise which resolves when the element matching `selector` is
* successfully hovered. Promise gets rejected if there's no element matching
* `selector`.
*
* @remarks
*
* Shortcut for {@link Page.hover | page.mainFrame().hover(selector)}.
*/
hover(selector: string): Promise<void> {
@ -2927,6 +2672,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @returns
*
* @remarks
*
* Shortcut for {@link Frame.select | page.mainFrame().select()}
*/
select(selector: string, ...values: string[]): Promise<string[]> {
@ -2942,13 +2688,10 @@ export abstract class Page extends EventEmitter<PageEvents> {
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | Selector}
* to search for element to tap. If there are multiple elements satisfying the
* selector, the first will be tapped.
*
* @remarks
*
* Shortcut for {@link Frame.tap | page.mainFrame().tap(selector)}.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
tap(selector: string): Promise<void> {
return this.mainFrame().tap(selector);
@ -2976,7 +2719,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @param options - have property `delay` which is the Time to wait between
* key presses in milliseconds. Defaults to `0`.
* @returns
* @remarks
*/
type(
selector: string,
@ -2992,6 +2734,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* Causes your script to wait for the given number of milliseconds.
*
* @remarks
*
* It's generally recommended to not wait for a number of seconds, but instead
* use {@link Frame.waitForSelector}, {@link Frame.waitForXPath} or
* {@link Frame.waitForFunction} to wait for exactly the conditions you want.
@ -3046,6 +2789,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @returns Promise which resolves when element specified by selector string
* is added to DOM. Resolves to `null` if waiting for hidden: `true` and
* selector is not found in DOM.
*
* @remarks
* The optional Parameter in Arguments `options` are:
*
@ -3060,13 +2804,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* - `timeout`: 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 {@link Page.setDefaultTimeout} method.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Partial support
*
* - ARIA selector not supported
*/
async waitForSelector<Selector extends string>(
selector: Selector,
@ -3223,11 +2960,6 @@ export abstract class Page extends EventEmitter<PageEvents> {
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
* );
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract waitForDevicePrompt(
options?: WaitTimeoutOptions

View File

@ -70,11 +70,6 @@ export abstract class Target {
/**
* Creates a Chrome Devtools Protocol session attached to the target.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract createCDPSession(): Promise<CDPSession>;
@ -99,11 +94,6 @@ export abstract class Target {
/**
* Get the target that opened this target. Top-level targets return `null`.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*/
abstract opener(): Target | undefined;
}

View File

@ -128,13 +128,6 @@ export interface SnapshotOptions {
* By default, Puppeteer tries to approximate this filtering, exposing only
* the "interesting" nodes of the tree.
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*
* @public
*/
export class Accessibility {

View File

@ -123,13 +123,6 @@ export interface CSSCoverageOptions {
* console.log(`Bytes used: ${(usedBytes / totalBytes) * 100}%`);
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*
* @public
*/
export class Coverage {

View File

@ -45,13 +45,6 @@ export interface TracingOptions {
* await page.tracing.stop();
* ```
*
* @privateRemarks BiDi
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | CDP}: Supported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi}: Unsupported
*
* {@link PROTOCOL_GET_STARTED_LINK_TEMPLATE | BiDi+}: Supported
*
* @public
*/
export class Tracing {

View File

@ -23,7 +23,7 @@ import type {ConnectionTransport} from './ConnectionTransport.js';
import type {Viewport} from './Viewport.js';
/**
* @internal
* @public
*/
export type ProtocolType = 'cdp' | 'webDriverBiDi';
@ -57,9 +57,10 @@ export interface BrowserConnectOptions {
* @internal
*/
_isPageTarget?: IsPageTargetCallback;
/**
* @defaultValue 'cdp'
* @internal
* @public
*/
protocol?: ProtocolType;
/**

View File

@ -95,8 +95,8 @@ export abstract class ProductLauncher {
slowMo = 0,
timeout = 30000,
waitForInitialPage = true,
protocol,
protocolTimeout,
protocol,
} = options;
const launchArgs = await this.computeLaunchArguments(options);

View File

@ -39,6 +39,7 @@ module.exports = {
},
],
},
'webdriver-bidi',
'chromium-support',
'troubleshooting',
'contributing',

View File

@ -32,7 +32,8 @@ non-standard DevTools Protocol used by Chrome).
The goals of the project are:
- Provide a slim, canonical library that highlights the capabilities of the
[DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/).
[DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) and
[WebDriver BiDi](https://w3c.github.io/webdriver-bidi/).
- Provide a reference implementation for similar testing libraries. Eventually,
these other frameworks could adopt Puppeteer as their foundational layer.
- Grow the adoption of headless/automated browser testing.