/**
* @license
* Copyright 2026 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
///
import type {ChildProcess} from 'node:child_process';
import {PassThrough} from 'node:stream';
import {Protocol} from 'devtools-protocol';
import type {ProtocolMapping} from 'devtools-protocol/types/protocol-mapping.js';
import type {ParseSelector} from 'typed-query-selector/parser.js';
import {Session} from 'webdriver-bidi-protocol';
/**
* The Accessibility class provides methods for inspecting the browser's
* accessibility tree. The accessibility tree is used by assistive technology
* such as {@link https://en.wikipedia.org/wiki/Screen_reader | screen readers} or
* {@link https://en.wikipedia.org/wiki/Switch_access | switches}.
*
* @remarks
*
* Accessibility is a very platform-specific thing. On different platforms,
* there are different screen readers that might have wildly different output.
*
* Blink - Chrome's rendering engine - has a concept of "accessibility tree",
* which is then translated into different platform-specific APIs. Accessibility
* namespace gives users access to the Blink Accessibility Tree.
*
* Most of the accessibility tree gets filtered out when converting from Blink
* AX Tree to Platform-specific AX-Tree or by assistive technologies themselves.
* By default, Puppeteer tries to approximate this filtering, exposing only
* the "interesting" nodes of the tree.
*
* @public
*/
export declare class Accessibility {
#private;
/**
* Captures the current state of the accessibility tree.
* The returned object represents the root accessible node of the page.
*
* @remarks
*
* **NOTE** The Chrome accessibility tree contains nodes that go unused on
* most platforms and by most screen readers. Puppeteer will discard them as
* well for an easier to process tree, unless `interestingOnly` is set to
* `false`.
*
* @example
* An example of dumping the entire accessibility tree:
*
* ```ts
* const snapshot = await page.accessibility.snapshot();
* console.log(snapshot);
* ```
*
* @example
* An example of logging the focused node's name:
*
* ```ts
* const snapshot = await page.accessibility.snapshot();
* const node = findFocusedNode(snapshot);
* console.log(node && node.name);
*
* function findFocusedNode(node) {
* if (node.focused) return node;
* for (const child of node.children || []) {
* const foundNode = findFocusedNode(child);
* return foundNode;
* }
* return null;
* }
* ```
*
* @returns An AXNode object representing the snapshot.
*/
snapshot(options?: SnapshotOptions): Promise;
private serializeTree;
private collectInterestingNodes;
}
/**
* @public
*/
export declare interface ActionOptions {
/**
* A signal to abort the locator action.
*/
signal?: AbortSignal;
}
/**
* @public
*/
export declare type ActionResult = 'continue' | 'abort' | 'respond';
/**
* @license
* Copyright 2025 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @public
* Emulated bluetooth adapter state.
*/
export declare type AdapterState = 'absent' | 'powered-off' | 'powered-on';
/**
* @public
*/
export declare interface AddScreenParams {
left: number;
top: number;
width: number;
height: number;
workAreaInsets?: WorkAreaInsets;
devicePixelRatio?: number;
rotation?: number;
colorDepth?: number;
label?: string;
isInternal?: boolean;
}
/**
* Supported autofill address field names.
*
* @public
*/
export declare const enum AutofillAddressField {
NameFirst = 'NAME_FIRST',
NameMiddle = 'NAME_MIDDLE',
NameLast = 'NAME_LAST',
NameFull = 'NAME_FULL',
EmailAddress = 'EMAIL_ADDRESS',
PhoneHomeNumber = 'PHONE_HOME_NUMBER',
PhoneHomeCityAndNumber = 'PHONE_HOME_CITY_AND_NUMBER',
PhoneHomeWholeNumber = 'PHONE_HOME_WHOLE_NUMBER',
AddressHomeLine1 = 'ADDRESS_HOME_LINE1',
AddressHomeLine2 = 'ADDRESS_HOME_LINE2',
AddressHomeStreetAddress = 'ADDRESS_HOME_STREET_ADDRESS',
AddressHomeCity = 'ADDRESS_HOME_CITY',
AddressHomeState = 'ADDRESS_HOME_STATE',
AddressHomeZip = 'ADDRESS_HOME_ZIP',
AddressHomeCountry = 'ADDRESS_HOME_COUNTRY',
}
/**
* @public
*/
export declare type AutofillData =
| {
/**
* See {@link https://chromedevtools.github.io/devtools-protocol/tot/Autofill/#type-CreditCard | Autofill.CreditCard}.
*/
creditCard: {
number: string;
name: string;
expiryMonth: string;
expiryYear: string;
cvc: string;
};
address?: never;
}
| {
/**
* See {@link https://chromedevtools.github.io/devtools-protocol/tot/Autofill/#type-Address | Autofill.Address}.
*/
address: {
fields: Array<{
/**
* The field type.
* See {@link https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/core/browser/field_types.cc}
* for the full list of supported fields.
*/
name: AutofillAddressField | (string & Record);
value: string;
}>;
};
creditCard?: never;
};
/**
* @public
*/
export declare type Awaitable = T | PromiseLike;
/**
* @public
*/
export declare type AwaitableIterable = Iterable | AsyncIterable;
/**
* @public
*/
export declare type AwaitablePredicate = (value: T) => Awaitable;
/**
* @public
*/
export declare type AwaitedLocator = T extends Locator ? S : never;
/**
* Exposes the bluetooth emulation abilities.
*
* @remarks {@link https://webbluetoothcg.github.io/web-bluetooth/#simulated-bluetooth-adapter|Web Bluetooth specification}
* requires the emulated adapters should be isolated per top-level navigable. However,
* at the moment Chromium's bluetooth emulation implementation is tight to the browser
* context, not the page. This means the bluetooth emulation exposed from different pages
* of the same browser context would interfere their states.
*
* @example
*
* ```ts
* await page.bluetooth.emulateAdapter('powered-on');
* await page.bluetooth.simulatePreconnectedPeripheral({
* address: '09:09:09:09:09:09',
* name: 'SOME_NAME',
* manufacturerData: [
* {
* key: 17,
* data: 'AP8BAX8=',
* },
* ],
* knownServiceUuids: ['12345678-1234-5678-9abc-def123456789'],
* });
* await page.bluetooth.disableEmulation();
* ```
*
* @experimental
* @public
*/
export declare interface BluetoothEmulation {
/**
* Emulate Bluetooth adapter. Required for bluetooth simulations
* See {@link https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateAdapter-command|bluetooth.simulateAdapter}.
*
* @param state - The desired bluetooth adapter state.
* @param leSupported - Mark if the adapter supports low-energy bluetooth.
*
* @experimental
* @public
*/
emulateAdapter(state: AdapterState, leSupported?: boolean): Promise;
/**
* Disable emulated bluetooth adapter.
* See {@link https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-disableSimulation-command|bluetooth.disableSimulation}.
*
* @experimental
* @public
*/
disableEmulation(): Promise;
/**
* Simulated preconnected Bluetooth Peripheral.
* See {@link https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateconnectedperipheral-command|bluetooth.simulatePreconnectedPeripheral}.
*
* @param preconnectedPeripheral - The peripheral to simulate.
*
* @experimental
* @public
*/
simulatePreconnectedPeripheral(
preconnectedPeripheral: PreconnectedPeripheral,
): Promise;
}
/**
* @public
* Represents the simulated bluetooth peripheral's manufacturer data.
*/
export declare interface BluetoothManufacturerData {
/**
* The company identifier, as defined by the {@link https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/|Bluetooth SIG}.
*/
key: number;
/**
* The manufacturer-specific data as a base64-encoded string.
*/
data: string;
}
/**
* @public
*/
export declare interface BoundingBox extends Point {
/**
* the width of the element in pixels.
*/
width: number;
/**
* the height of the element in pixels.
*/
height: number;
}
/**
* @public
*/
export declare interface BoxModel {
content: Quad;
padding: Quad;
border: Quad;
margin: Quad;
width: number;
height: number;
}
/**
* {@link Browser} represents a browser instance that is either:
*
* - connected to via {@link Puppeteer.connect} or
* - launched by {@link PuppeteerNode.launch}.
*
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
* documented in the {@link BrowserEvent} enum.
*
* @example Using a {@link Browser} to create a {@link Page}:
*
* ```ts
* import puppeteer from 'puppeteer';
*
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.goto('https://example.com');
* await browser.close();
* ```
*
* @example Disconnecting from and reconnecting to a {@link Browser}:
*
* ```ts
* import puppeteer from 'puppeteer';
*
* const browser = await puppeteer.launch();
* // Store the endpoint to be able to reconnect to the browser.
* const browserWSEndpoint = browser.wsEndpoint();
* // Disconnect puppeteer from the browser.
* await browser.disconnect();
*
* // Use the endpoint to reestablish a connection
* const browser2 = await puppeteer.connect({browserWSEndpoint});
* // Close the browser.
* await browser2.close();
* ```
*
* @public
*/
export declare abstract class Browser extends EventEmitter {
/**
* Gets the associated
* {@link https://nodejs.org/api/child_process.html#class-childprocess | ChildProcess}.
*
* @returns `null` if this instance was connected to via
* {@link Puppeteer.connect}.
*/
abstract process(): ChildProcess | null;
/**
* Creates a new {@link BrowserContext | browser context}.
*
* This won't share cookies/cache with other {@link BrowserContext | browser contexts}.
*
* @example
*
* ```ts
* import puppeteer from 'puppeteer';
*
* const browser = await puppeteer.launch();
* // Create a new browser context.
* const context = await browser.createBrowserContext();
* // Create a new page in a pristine context.
* const page = await context.newPage();
* // Do stuff
* await page.goto('https://example.com');
* ```
*/
abstract createBrowserContext(
options?: BrowserContextOptions,
): Promise;
/**
* Gets a list of open {@link BrowserContext | browser contexts}.
*
* In a newly-created {@link Browser | browser}, this will return a single
* instance of {@link BrowserContext}.
*/
abstract browserContexts(): BrowserContext[];
/**
* Gets the default {@link BrowserContext | browser context}.
*
* @remarks The default {@link BrowserContext | browser context} cannot be
* closed.
*/
abstract defaultBrowserContext(): BrowserContext;
/**
* Gets the WebSocket URL to connect to this {@link Browser | browser}.
*
* This is usually used with {@link Puppeteer.connect}.
*
* You can find the debugger URL (`webSocketDebuggerUrl`) from
* `http://HOST:PORT/json/version`.
*
* See {@link https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target | browser endpoint}
* for more information.
*
* @remarks The format is always `ws://HOST:PORT/devtools/browser/`.
*/
abstract wsEndpoint(): string;
/**
* Creates a new {@link Page | page} in the
* {@link Browser.defaultBrowserContext | default browser context}.
*/
abstract newPage(options?: CreatePageOptions): Promise;
/**
* Gets the specified window {@link WindowBounds | bounds}.
*/
abstract getWindowBounds(windowId: WindowId): Promise;
/**
* Sets the specified window {@link WindowBounds | bounds}.
*/
abstract setWindowBounds(
windowId: WindowId,
windowBounds: WindowBounds,
): Promise;
/**
* Gets all active {@link Target | targets}.
*
* In case of multiple {@link BrowserContext | browser contexts}, this returns
* all {@link Target | targets} in all
* {@link BrowserContext | browser contexts}.
*/
abstract targets(): Target[];
/**
* Gets the {@link Target | target} associated with the
* {@link Browser.defaultBrowserContext | default browser context}).
*/
abstract target(): Target;
/**
* Waits until a {@link Target | target} matching the given `predicate`
* appears and returns it.
*
* This will look all open {@link BrowserContext | browser contexts}.
*
* @example Finding a target for a page opened via `window.open`:
*
* ```ts
* await page.evaluate(() => window.open('https://www.example.com/'));
* const newWindowTarget = await browser.waitForTarget(
* target => target.url() === 'https://www.example.com/',
* );
* ```
*/
waitForTarget(
predicate: (x: Target) => boolean | Promise,
options?: WaitForTargetOptions,
): Promise;
/**
* Gets a list of all open {@link Page | pages} inside this {@link Browser}.
*
* If there are multiple {@link BrowserContext | browser contexts}, this
* returns all {@link Page | pages} in all
* {@link BrowserContext | browser contexts}.
*
* @param includeAll - experimental, setting to true includes all kinds of pages.
*
* @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
* will not be listed here. You can find them using {@link Target.page}.
*/
pages(includeAll?: boolean): Promise;
/**
* Gets a string representing this {@link Browser | browser's} name and
* version.
*
* For headless browser, this is similar to `"HeadlessChrome/61.0.3153.0"`. For
* non-headless or new-headless, this is similar to `"Chrome/61.0.3153.0"`. For
* Firefox, it is similar to `"Firefox/116.0a1"`.
*
* The format of {@link Browser.version} might change with future releases of
* browsers.
*/
abstract version(): Promise;
/**
* Gets this {@link Browser | browser's} original user agent.
*
* {@link Page | Pages} can override the user agent with
* {@link Page.(setUserAgent:2) }.
*
*/
abstract userAgent(): Promise;
/**
* Closes this {@link Browser | browser} and all associated
* {@link Page | pages}.
*/
abstract close(): Promise;
/**
* Disconnects Puppeteer from this {@link Browser | browser}, but leaves the
* process running.
*/
abstract disconnect(): Promise;
/**
* Returns all cookies in the default {@link BrowserContext}.
*
* @remarks
*
* Shortcut for
* {@link BrowserContext.cookies | browser.defaultBrowserContext().cookies()}.
*/
cookies(): Promise;
/**
* Sets cookies in the default {@link BrowserContext}.
*
* @remarks
*
* Shortcut for
* {@link BrowserContext.setCookie | browser.defaultBrowserContext().setCookie()}.
*/
setCookie(...cookies: CookieData[]): Promise;
/**
* Removes cookies from the default {@link BrowserContext}.
*
* @remarks
*
* Shortcut for
* {@link BrowserContext.deleteCookie | browser.defaultBrowserContext().deleteCookie()}.
*/
deleteCookie(...cookies: Cookie[]): Promise;
/**
* Deletes cookies matching the provided filters from the default
* {@link BrowserContext}.
*
* @remarks
*
* Shortcut for
* {@link BrowserContext.deleteMatchingCookies |
* browser.defaultBrowserContext().deleteMatchingCookies()}.
*/
deleteMatchingCookies(...filters: DeleteCookiesRequest[]): Promise;
/**
* Sets the permission for a specific origin in the default
* {@link BrowserContext}.
*
* @remarks
*
* Shortcut for
* {@link BrowserContext.setPermission |
* browser.defaultBrowserContext().setPermission()}.
*
* @param origin - The origin to set the permission for.
* @param permission - The permission descriptor.
* @param state - The state of the permission.
*
* @public
*/
setPermission(
origin: string,
...permissions: Array<{
permission: PermissionDescriptor_2;
state: PermissionState_2;
}>
): Promise;
/**
* Installs an extension and returns the ID. In Chrome, this is only
* available if the browser was created using `pipe: true` and the
* `--enable-unsafe-extension-debugging` flag is set.
*/
abstract installExtension(path: string): Promise;
/**
* Uninstalls an extension. In Chrome, this is only available if the browser
* was created using `pipe: true` and the
* `--enable-unsafe-extension-debugging` flag is set.
*/
abstract uninstallExtension(id: string): Promise;
/**
* Gets a list of {@link ScreenInfo | screen information objects}.
*/
abstract screens(): Promise;
/**
* Adds a new screen, returns the added {@link ScreenInfo | screen information object}.
*
* @remarks
*
* Only supported in headless mode.
*/
abstract addScreen(params: AddScreenParams): Promise;
/**
* Removes a screen.
*
* @remarks
*
* Only supported in headless mode. Fails if the primary screen id is specified.
*/
abstract removeScreen(screenId: string): Promise;
/**
* Whether Puppeteer is connected to this {@link Browser | browser}.
*/
abstract get connected(): boolean;
/**
* Get debug information from Puppeteer.
*
* @remarks
*
* Currently, includes pending protocol calls. In the future, we might add more info.
*
* @public
* @experimental
*/
abstract get debugInfo(): DebugInfo;
/**
* Retrieves a map of all extensions installed in the browser, where the keys
* are extension IDs and the values are the corresponding {@link Extension} instances.
*
* @public
*/
abstract extensions(): Promise