/**
* @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.
*/
abstract installExtension(
path: string,
options?: ExtensionInstallOptions,
): Promise;
/**
* Uninstalls an extension.
*/
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>;
}
/**
* {@link BrowserContext} represents individual user contexts within a
* {@link Browser | browser}.
*
* When a {@link Browser | browser} is launched, it has at least one default
* {@link BrowserContext | browser context}. Others can be created
* using {@link Browser.createBrowserContext}. Each context has isolated storage
* (cookies/localStorage/etc.)
*
* {@link BrowserContext} {@link EventEmitter | emits} various events which are
* documented in the {@link BrowserContextEvent} enum.
*
* If a {@link Page | page} opens another {@link Page | page}, e.g. using
* `window.open`, the popup will belong to the parent {@link Page.browserContext
* | page's browser context}.
*
* @example Creating a new {@link BrowserContext | browser context}:
*
* ```ts
* // Create a new browser context
* const context = await browser.createBrowserContext();
* // Create a new page inside context.
* const page = await context.newPage();
* // ... do stuff with page ...
* await page.goto('https://example.com');
* // Dispose context once it's no longer needed.
* await context.close();
* ```
*
* @remarks
*
* In Chrome all non-default contexts are incognito,
* and {@link Browser.defaultBrowserContext | default browser context}
* might be incognito if you provide the `--incognito` argument when launching
* the browser.
*
* @public
*/
export declare abstract class BrowserContext extends EventEmitter {
#private;
/**
* Gets all active {@link Target | targets} inside this
* {@link BrowserContext | browser context}.
*/
abstract targets(): 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 browserContext.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 BrowserContext | browser context}.
*
* @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}.
*/
abstract pages(includeAll?: boolean): Promise;
/**
* Grants this {@link BrowserContext | browser context} the given
* `permissions` within the given `origin`.
*
* @example Overriding permissions in the
* {@link Browser.defaultBrowserContext | default browser context}:
*
* ```ts
* const context = browser.defaultBrowserContext();
* await context.overridePermissions('https://html5demos.com', [
* 'geolocation',
* ]);
* ```
*
* @param origin - The origin to grant permissions to, e.g.
* "https://example.com".
* @param permissions - An array of permissions to grant. All permissions that
* are not listed here will be automatically denied.
*
* @deprecated in favor of {@link BrowserContext.setPermission}.
*/
abstract overridePermissions(
origin: string,
permissions: Permission[],
): Promise;
/**
* Sets the permission for a specific origin.
*
* @param origin - The origin to set the permission for.
* @param permission - The permission descriptor.
* @param state - The state of the permission.
*
* @public
*/
abstract setPermission(
origin: string | '*',
...permissions: Array<{
permission: PermissionDescriptor_2;
state: PermissionState_2;
}>
): Promise;
/**
* Clears all permission overrides for this
* {@link BrowserContext | browser context}.
*
* @example Clearing overridden permissions in the
* {@link Browser.defaultBrowserContext | default browser context}:
*
* ```ts
* const context = browser.defaultBrowserContext();
* context.overridePermissions('https://example.com', ['clipboard-read']);
* // do stuff ..
* context.clearPermissionOverrides();
* ```
*/
abstract clearPermissionOverrides(): Promise;
/**
* Creates a new {@link Page | page} in this
* {@link BrowserContext | browser context}.
*/
abstract newPage(options?: CreatePageOptions): Promise;
/**
* Gets the {@link Browser | browser} associated with this
* {@link BrowserContext | browser context}.
*/
abstract browser(): Browser;
/**
* Closes this {@link BrowserContext | browser context} and all associated
* {@link Page | pages}.
*
* @remarks The
* {@link Browser.defaultBrowserContext | default browser context} cannot be
* closed.
*/
abstract close(): Promise;
/**
* Gets all cookies in the browser context.
*/
abstract cookies(): Promise;
/**
* Sets a cookie in the browser context.
*/
abstract setCookie(...cookies: CookieData[]): Promise;
/**
* Removes cookie in this browser context.
*
* @param cookies - Complete {@link Cookie | cookie} object to be removed.
*/
deleteCookie(...cookies: Cookie[]): Promise;
/**
* Deletes cookies matching the provided filters in this browser context.
*
* @param filters - {@link DeleteCookiesRequest}
*/
deleteMatchingCookies(...filters: DeleteCookiesRequest[]): Promise;
/**
* Whether this {@link BrowserContext | browser context} is closed.
*/
get closed(): boolean;
/**
* Identifier for this {@link BrowserContext | browser context}.
*/
get id(): string | undefined;
}
/**
* @public
*/
export declare const enum BrowserContextEvent {
/**
* Emitted when the url of a target inside the browser context changes.
* Contains a {@link Target} instance.
*/
TargetChanged = 'targetchanged',
/**
* Emitted when a target is created within the browser context, for example
* when a new page is opened by
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
* or by {@link BrowserContext.newPage | browserContext.newPage}
*
* Contains a {@link Target} instance.
*/
TargetCreated = 'targetcreated',
/**
* Emitted when a target is destroyed within the browser context, for example
* when a page is closed. Contains a {@link Target} instance.
*/
TargetDestroyed = 'targetdestroyed',
}
/**
* @public
*/
export declare interface BrowserContextEvents extends Record<
EventType,
unknown
> {
[BrowserContextEvent.TargetChanged]: Target;
[BrowserContextEvent.TargetCreated]: Target;
[BrowserContextEvent.TargetDestroyed]: Target;
}
/**
* @public
*/
export declare interface BrowserContextOptions {
/**
* Proxy server with optional port to use for all requests.
* Username and password can be set in `Page.authenticate`.
*/
proxyServer?: string;
/**
* Bypass the proxy for the given list of hosts.
*/
proxyBypassList?: string[];
/**
* Behavior definition for when downloading a file.
*
* @remarks
* If not set, the default behavior will be used.
*/
downloadBehavior?: DownloadBehavior;
}
/**
* All the events a {@link Browser | browser instance} may emit.
*
* @public
*/
export declare const enum BrowserEvent {
/**
* Emitted when Puppeteer gets disconnected from the browser instance. This
* might happen because either:
*
* - The browser closes/crashes or
* - {@link Browser.disconnect} was called.
*/
Disconnected = 'disconnected',
/**
* Emitted when the URL of a target changes. Contains a {@link Target}
* instance.
*
* @remarks Note that this includes target changes in all browser
* contexts.
*/
TargetChanged = 'targetchanged',
/**
* Emitted when a target is created, for example when a new page is opened by
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
* or by {@link Browser.newPage | browser.newPage}
*
* Contains a {@link Target} instance.
*
* @remarks Note that this includes target creations in all browser
* contexts.
*/
TargetCreated = 'targetcreated',
/**
* Emitted when a target is destroyed, for example when a page is closed.
* Contains a {@link Target} instance.
*
* @remarks Note that this includes target destructions in all browser
* contexts.
*/
TargetDestroyed = 'targetdestroyed',
}
/**
* @public
*/
export declare interface BrowserEvents extends Record {
[BrowserEvent.Disconnected]: undefined;
[BrowserEvent.TargetCreated]: Target;
[BrowserEvent.TargetDestroyed]: Target;
[BrowserEvent.TargetChanged]: Target;
}
/**
* Describes a launcher - a class that is able to create and launch a browser instance.
*
* @public
*/
export declare abstract class BrowserLauncher {
#private;
get browser(): SupportedBrowser;
launch(options?: LaunchOptions): Promise;
abstract executablePath(
channel?: ChromeReleaseChannel,
validatePath?: boolean,
): Promise;
abstract defaultArgs(object: LaunchOptions): string[];
}
/**
* @public
*/
export declare type CDPEvents = {
[
Property in keyof ProtocolMapping.Events
]: ProtocolMapping.Events[Property][0];
};
/**
* The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
*
* @remarks
*
* Protocol methods can be called with {@link CDPSession.send} method and protocol
* events can be subscribed to with `CDPSession.on` method.
*
* Useful links: {@link https://chromedevtools.github.io/devtools-protocol/ | DevTools Protocol Viewer}
* and {@link https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md | Getting Started with DevTools Protocol}.
*
* @example
*
* ```ts
* const client = await page.createCDPSession();
* await client.send('Animation.enable');
* client.on('Animation.animationCreated', () =>
* console.log('Animation created!'),
* );
* const response = await client.send('Animation.getPlaybackRate');
* console.log('playback rate is ' + response.playbackRate);
* await client.send('Animation.setPlaybackRate', {
* playbackRate: response.playbackRate / 2,
* });
* ```
*
* @public
*/
export declare abstract class CDPSession extends EventEmitter {
/**
* The underlying connection for this session, if any.
*
* @public
*/
abstract connection(): Connection | undefined;
/**
* True if the session has been detached, false otherwise.
*
* @public
*/
abstract get detached(): boolean;
abstract send(
method: T,
params?: ProtocolMapping.Commands[T]['paramsType'][0],
options?: CommandOptions,
): Promise;
/**
* Detaches the cdpSession from the target. Once detached, the cdpSession object
* won't emit any events and can't be used to send messages.
*/
abstract detach(): Promise;
/**
* Returns the session's id.
*/
abstract id(): string;
}
/**
* Events that the CDPSession class emits.
*
* @public
*/
export declare namespace CDPSessionEvent {
const SessionAttached: 'sessionattached';
const SessionDetached: 'sessiondetached';
}
/**
* @public
*/
export declare interface CDPSessionEvents
extends CDPEvents, Record {
[CDPSessionEvent.SessionAttached]: CDPSession;
[CDPSessionEvent.SessionDetached]: CDPSession;
}
/**
* @public
*/
export declare interface ChromeHeadlessShellSettings {
/**
* Tells Puppeteer to not download the browser during installation.
*
* Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_SKIP_DOWNLOAD`
* or `PUPPETEER_SKIP_CHROME_HEADLESS_SHELL_DOWNLOAD`.
*
* @defaultValue false
*/
skipDownload?: boolean;
/**
* Specifies the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*
* @defaultValue https://storage.googleapis.com/chrome-for-testing-public
*/
downloadBaseUrl?: string;
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_VERSION`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @example 119.0.6045.105
* @defaultValue The pinned browser version supported by the current Puppeteer
* version.
*/
version?: string;
}
/**
* @public
*/
export declare type ChromeReleaseChannel =
'chrome' | 'chrome-beta' | 'chrome-canary' | 'chrome-dev';
/**
* @public
*/
export declare interface ChromeSettings {
/**
* Tells Puppeteer to not download the browser during installation.
*
* Can be overridden by `PUPPETEER_CHROME_SKIP_DOWNLOAD`.
*
* @defaultValue false
*/
skipDownload?: boolean;
/**
* Specifies the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_CHROME_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*
* @defaultValue https://storage.googleapis.com/chrome-for-testing-public
*/
downloadBaseUrl?: string;
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_CHROME_VERSION`
* or `PUPPETEER_SKIP_CHROME_DOWNLOAD`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @example 119.0.6045.105
* @defaultValue The pinned browser version supported by the current Puppeteer
* version.
*/
version?: string;
}
/**
* @public
*/
export declare interface ClickOptions extends MouseClickOptions {
/**
* Offset for the clickable point relative to the top-left corner of the border box.
*/
offset?: Offset;
/**
* An experimental debugging feature. If true, inserts an element into the
* page to highlight the click location for 10 seconds. Might not work on all
* pages and does not persist across navigations.
*
* @experimental
*/
debugHighlight?: boolean;
}
/**
* @public
*/
export declare interface CommandOptions {
timeout: number;
}
/**
* @public
*/
export declare interface CommonEventEmitter<
Events extends Record,
> {
on(type: Key, handler: Handler): this;
off(
type: Key,
handler?: Handler,
): this;
emit(type: Key, event: Events[Key]): boolean;
once(
type: Key,
handler: Handler,
): this;
listenerCount(event: keyof Events): number;
removeAllListeners(event?: keyof Events): this;
}
/**
* Defines options to configure Puppeteer's behavior during installation and
* runtime.
*
* See individual properties for more information.
*
* @public
*/
export declare interface Configuration {
/**
* Defines the directory to be used by Puppeteer for caching.
*
* Can be overridden by `PUPPETEER_CACHE_DIR`.
*
* @defaultValue `path.join(os.homedir(), '.cache', 'puppeteer')`
*/
cacheDirectory?: string;
/**
* Specifies an executable path to be used in
* {@link PuppeteerNode.launch | puppeteer.launch}.
*
* Can be overridden by `PUPPETEER_EXECUTABLE_PATH`.
*
* @defaultValue **Auto-computed.**
*/
executablePath?: string;
/**
* Specifies which browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_BROWSER`.
*
* @defaultValue `chrome`
*/
defaultBrowser?: SupportedBrowser;
/**
* Defines the directory to be used by Puppeteer for creating temporary files.
*
* Can be overridden by `PUPPETEER_TMP_DIR`.
*
* @defaultValue `os.tmpdir()`
*/
temporaryDirectory?: string;
/**
* Tells Puppeteer to not download any of the browsers during installation.
*
* Can be overridden by `PUPPETEER_SKIP_DOWNLOAD` or by specifying either
* `skipDownload` property in each browser specific config or by providing
* `PUPPETEER_FIREFOX_SKIP_DOWNLOAD` and `PUPPETEER_CHROME_SKIP_DOWNLOAD`.
*/
skipDownload?: boolean;
/**
* Tells Puppeteer to log at the given level.
*
* @defaultValue `warn`
*/
logLevel?: 'silent' | 'error' | 'warn';
/**
* Defines experimental options for Puppeteer.
*/
experiments?: ExperimentsConfiguration;
chrome?: ChromeSettings;
['chrome-headless-shell']?: ChromeHeadlessShellSettings;
firefox?: FirefoxSettings;
}
/**
* @public
*/
export declare const /**
* @public
*/
/**
* @public
*/
connect: (
options: Puppeteer_2.ConnectOptions,
) => Promise;
/**
* @public
*/
export declare class Connection extends EventEmitter {
#private;
constructor(
url: string,
transport: ConnectionTransport,
delay?: number,
timeout?: number,
rawErrors?: boolean,
idGenerator?: () => number,
);
static fromSession(session: CDPSession): Connection | undefined;
get timeout(): number;
/**
* @param sessionId - The session id
* @returns The current CDP session if it exists
*/
session(sessionId: string): CDPSession | null;
url(): string;
send(
method: T,
params?: ProtocolMapping.Commands[T]['paramsType'][0],
options?: CommandOptions,
): Promise;
dispose(): void;
/**
* @param targetInfo - The target info
* @returns The CDP session that is created
*/
createSession(targetInfo: Protocol.Target.TargetInfo): Promise;
}
/**
* Thrown if underlying protocol connection has been closed.
*
* @public
*/
export declare class ConnectionClosedError extends ProtocolError {}
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @public
*/
export declare interface ConnectionTransport {
send(message: string): void;
close(): void;
onmessage?: (message: string) => void;
onclose?: () => void;
}
/**
* Generic browser options that can be passed when launching any browser or when
* connecting to an existing browser instance.
* @public
*/
export declare interface ConnectOptions {
/**
* Whether to ignore HTTPS errors during navigation.
* @defaultValue `false`
*/
acceptInsecureCerts?: boolean;
/**
* If specified, puppeteer looks for an open WebSocket at the well-known
* default user data directory for the specified channel and attempts to
* connect to it using ws://localhost:$ActivePort/devtools/browser. Only works
* for Chrome and when run in Node.js.
*
* This option is experimental when used with puppeteer.connect().
*
* @experimental
*/
channel?: ChromeReleaseChannel;
/**
* Experimental setting to disable monitoring network events by default. When
* set to `false`, parts of Puppeteer that depend on network events would not
* work such as HTTPRequest and HTTPResponse.
*
* @experimental
* @defaultValue `true`
*/
networkEnabled?: boolean;
/**
* Experimental setting to disable monitoring issue events by default.
*
* @experimental
* @defaultValue `true`
*/
issuesEnabled?: boolean;
/**
* Sets the viewport for each page.
*
* @defaultValue '\{width: 800, height: 600\}'
*/
defaultViewport?: Viewport | null;
/**
* Sets the download behavior for the context.
*/
downloadBehavior?: DownloadBehavior;
/**
* Slows down Puppeteer operations by the specified amount of milliseconds to
* aid debugging.
*/
slowMo?: number;
/**
* Callback to decide if Puppeteer should connect to a given target or not.
*/
targetFilter?: TargetFilterCallback;
/**
* Whether to handle the DevTools windows as pages in Puppeteer. Supported
* only in Chrome with CDP.
*
* @defaultValue 'false'
*/
handleDevToolsAsPage?: boolean;
/**
* @defaultValue Determined at run time:
*
* - Launching Chrome - 'cdp'.
*
* - Launching Firefox - 'webDriverBiDi'.
*
* - Connecting to a browser - 'cdp'.
*
* @public
*/
protocol?: ProtocolType;
/**
* Timeout setting for individual protocol (CDP) calls.
*
* @defaultValue `180_000`
*/
protocolTimeout?: number;
browserWSEndpoint?: string;
browserURL?: string;
transport?: ConnectionTransport;
/**
* Headers to use for the web socket connection.
* @remarks
* Only works in the Node.js environment.
*/
headers?: Record;
/**
* WebDriver BiDi capabilities passed to BiDi `session.new`.
*
* @remarks
* Only works for `protocol="webDriverBiDi"` and {@link Puppeteer.connect}.
*/
capabilities?: SupportedWebDriverCapabilities;
/**
* A list of URL patterns to block.
*
* This option allows you to restrict the browser from accessing specific URLs
* or origins. It uses the standard
* [URLPattern](https://urlpattern.spec.whatwg.org/) API to match URLs.
*
* When connecting to an existing browser, Puppeteer will silently detach from
* any already open targets that violate the patterns.
*
* For any network requests made by the browser (including navigations and
* subresources like images or scripts), the request will fail with an error
* if the URL matches a blocked pattern.
*
* @example Pattern to block a specific domain: `*://example.com/*`
*
* @example Pattern to block all subdomains: `*://*.evil.com/*`
*
* @remarks
* Currently only supported for Chrome.
*
* The feature works while Puppeteer is attached to the CDP targets.
* It intercepts requests in the network service in Chrome.
* Chrome may perform some network access in other ways or
* some web features may omit the network service.
* The feature is meant as an additional guardrails to LLM-based
* usage under Puppeteer control and not a complete network sandbox.
* For complete network sandboxing, we recommend using
* container/OS-level sandbox mechanism.
*
* Cannot be used along with {@link ConnectOptions.allowlist}.
*
* @experimental
*/
blocklist?: string[];
/**
* A list of URL patterns to allow.
*
* **Requires Chrome 149+.**
*
* This option allows you to restrict the browser from accessing any URLs
* except for those that match the patterns in the allowList.
* It uses the standard [URLPattern](https://urlpattern.spec.whatwg.org/) API to match URLs.
*
* When connecting to an existing browser, Puppeteer will silently detach from any
* already open targets that violate the patterns.
*
* For any network requests made by the browser (including navigations and
* subresources like images or scripts), the request will fail with an error
* if the URL does not match any pattern in the allowlist.
*
* @example Pattern to allow a specific domain:
* `*://example.com/*`
*
* @example Pattern to allow all subdomains:
* `*://*.example.com/*`
*
* @remarks
* Currently only supported for Chrome.
*
* The feature works while Puppeteer is attached to the CDP targets.
* It intercepts requests in the network service in Chrome.
* Chrome may perform some network access in other ways or
* some web features may omit the network service.
* The feature is meant as an additional guardrails to LLM-based
* usage under Puppeteer control and not a complete network sandbox.
* For complete network sandboxing, we recommend using
* container/OS-level sandbox mechanism.
*
* Cannot be used along with {@link ConnectOptions.blocklist}.
*
* @experimental
*/
allowlist?: string[];
}
/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
export declare class ConsoleMessage {
#private;
/**
* The type of the console message.
*/
type(): ConsoleMessageType;
/**
* The text of the console message.
*/
text(): string;
/**
* An array of arguments passed to the console.
*/
args(): JSHandle[];
/**
* The location of the console message.
*/
location(): ConsoleMessageLocation;
/**
* The array of locations on the stack of the console message.
*/
stackTrace(): ConsoleMessageLocation[];
}
/**
* @public
*/
export declare interface ConsoleMessageLocation {
/**
* URL of the resource if known or `undefined` otherwise.
*/
url?: string;
/**
* 0-based line number in the resource if known or `undefined` otherwise.
*/
lineNumber?: number;
/**
* 0-based column number in the resource if known or `undefined` otherwise.
*/
columnNumber?: number;
}
/**
* The supported types for console messages.
* @public
*/
export declare type ConsoleMessageType =
| 'log'
| 'debug'
| 'info'
| 'error'
| 'warn'
| 'dir'
| 'dirxml'
| 'table'
| 'trace'
| 'clear'
| 'startGroup'
| 'startGroupCollapsed'
| 'endGroup'
| 'assert'
| 'profile'
| 'profileEnd'
| 'count'
| 'timeEnd'
| 'verbose';
/**
* @public
*/
export declare interface ContinueRequestOverrides {
/**
* If set, the request URL will change. This is not a redirect.
*/
url?: string;
method?: string;
postData?: string;
headers?: Record;
}
/**
* Represents a cookie object.
*
* @public
*/
export declare interface Cookie extends CookieData {
/**
* Cookie path.
*/
path: string;
/**
* Cookie expiration date as the number of seconds since the UNIX epoch. Set to `-1` for
* session cookies
*/
expires: number;
/**
* Cookie size.
*/
size: number;
/**
* True if cookie is secure.
*/
secure: boolean;
/**
* True in case of session cookie.
*/
session: boolean;
/**
* True if cookie partition key is opaque. Supported only in Chrome.
*/
partitionKeyOpaque?: boolean;
}
/**
* Cookie parameter object used to set cookies in the browser-level cookies
* API.
*
* @public
*/
export declare interface CookieData {
/**
* Cookie name.
*/
name: string;
/**
* Cookie value.
*/
value: string;
/**
* Cookie domain.
*/
domain: string;
/**
* Cookie path.
*/
path?: string;
/**
* True if cookie is secure.
*/
secure?: boolean;
/**
* True if cookie is http-only.
*/
httpOnly?: boolean;
/**
* Cookie SameSite type.
*/
sameSite?: CookieSameSite_2;
/**
* Cookie expiration date, session cookie if not set
*/
expires?: number;
/**
* Cookie Priority. Supported only in Chrome.
*/
priority?: CookiePriority;
/**
* Cookie source scheme type. Supported only in Chrome.
*/
sourceScheme?: CookieSourceScheme;
/**
* Cookie partition key. In Chrome, it matches the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin in the
* {@link https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey | PartitionKey }.
*/
partitionKey?: CookiePartitionKey | string;
}
/**
* Cookie parameter object used to set cookies in the page-level cookies
* API.
*
* @public
*/
export declare interface CookieParam {
/**
* Cookie name.
*/
name: string;
/**
* Cookie value.
*/
value: string;
/**
* The request-URI to associate with the setting of the cookie. This value can affect
* the default domain, path, and source scheme values of the created cookie.
*/
url?: string;
/**
* Cookie domain.
*/
domain?: string;
/**
* Cookie path.
*/
path?: string;
/**
* True if cookie is secure.
*/
secure?: boolean;
/**
* True if cookie is http-only.
*/
httpOnly?: boolean;
/**
* Cookie SameSite type.
*/
sameSite?: CookieSameSite_2;
/**
* Cookie expiration date, session cookie if not set
*/
expires?: number;
/**
* Cookie Priority. Supported only in Chrome.
*/
priority?: CookiePriority;
/**
* Cookie source scheme type. Supported only in Chrome.
*/
sourceScheme?: CookieSourceScheme;
/**
* Cookie partition key. In Chrome, it matches the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin in the
* {@link https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey | PartitionKey }.
*/
partitionKey?: CookiePartitionKey | string;
}
/**
* Represents a cookie partition key in Chrome.
*
* @public
*/
export declare interface CookiePartitionKey {
/**
* The site of the top-level URL the browser was visiting at the start of the request
* to the endpoint that set the cookie.
*
* In Chrome, maps to the CDP's `topLevelSite` partition key.
*/
sourceOrigin: string;
/**
* Indicates if the cookie has any ancestors that are cross-site to
* the topLevelSite.
*
* Supported only in Chrome.
*/
hasCrossSiteAncestor?: boolean;
}
/**
* Represents the cookie's 'Priority' status:
* https://tools.ietf.org/html/draft-west-cookie-priority-00
*
* @public
*/
export declare type CookiePriority = 'Low' | 'Medium' | 'High';
/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Represents the cookie's 'SameSite' status:
* https://tools.ietf.org/html/draft-west-first-party-cookies
*
* @public
*/
declare type CookieSameSite_2 = 'Strict' | 'Lax' | 'None' | 'Default';
export type {CookieSameSite_2 as CookieSameSite};
/**
* Represents the source scheme of the origin that originally set the cookie. A value of
* "Unset" allows protocol clients to emulate legacy cookie scope for the scheme.
* This is a temporary ability and it will be removed in the future.
*
* @public
*/
export declare type CookieSourceScheme = 'Unset' | 'NonSecure' | 'Secure';
/**
* The Coverage class provides methods to gather information about parts of
* JavaScript and CSS that were used by the page.
*
* @remarks
* To output coverage in a form consumable by {@link https://github.com/istanbuljs | Istanbul},
* see {@link https://github.com/istanbuljs/puppeteer-to-istanbul | puppeteer-to-istanbul}.
*
* @example
* An example of using JavaScript and CSS coverage to get percentage of initially
* executed code:
*
* ```ts
* // Enable both JavaScript and CSS coverage
* await Promise.all([
* page.coverage.startJSCoverage(),
* page.coverage.startCSSCoverage(),
* ]);
* // Navigate to page
* await page.goto('https://example.com');
* // Disable both JavaScript and CSS coverage
* const [jsCoverage, cssCoverage] = await Promise.all([
* page.coverage.stopJSCoverage(),
* page.coverage.stopCSSCoverage(),
* ]);
* let totalBytes = 0;
* let usedBytes = 0;
* const coverage = [...jsCoverage, ...cssCoverage];
* for (const entry of coverage) {
* totalBytes += entry.text.length;
* for (const range of entry.ranges) usedBytes += range.end - range.start - 1;
* }
* console.log(`Bytes used: ${(usedBytes / totalBytes) * 100}%`);
* ```
*
* @public
*/
export declare class Coverage {
#private;
/**
* @param options - Set of configurable options for coverage defaults to
* `resetOnNavigation : true, reportAnonymousScripts : false,`
* `includeRawScriptCoverage : false, useBlockCoverage : true`
* @returns Promise that resolves when coverage is started.
*
* @remarks
* Anonymous scripts are ones that don't have an associated url. These are
* scripts that are dynamically created on the page using `eval` or
* `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous
* scripts URL will start with `debugger://VM` (unless a magic //# sourceURL
* comment is present, in which case that will the be URL).
*/
startJSCoverage(options?: JSCoverageOptions): Promise;
/**
* Promise that resolves to the array of coverage reports for
* all scripts.
*
* @remarks
* JavaScript Coverage doesn't include anonymous scripts by default.
* However, scripts with sourceURLs are reported.
*/
stopJSCoverage(): Promise;
/**
* @param options - Set of configurable options for coverage, defaults to
* `resetOnNavigation : true`
* @returns Promise that resolves when coverage is started.
*/
startCSSCoverage(options?: CSSCoverageOptions): Promise;
/**
* Promise that resolves to the array of coverage reports
* for all stylesheets.
*
* @remarks
* CSS Coverage doesn't include dynamically injected style tags
* without sourceURLs.
*/
stopCSSCoverage(): Promise;
}
/**
* The CoverageEntry class represents one entry of the coverage report.
* @public
*/
export declare interface CoverageEntry {
/**
* The URL of the style sheet or script.
*/
url: string;
/**
* The content of the style sheet or script.
*/
text: string;
/**
* The covered range as start and end positions.
*/
ranges: Array<{
start: number;
end: number;
}>;
}
/**
* @public
*/
export declare type CreatePageOptions = (
| {
type?: 'tab';
}
| {
type: 'window';
windowBounds?: WindowBounds;
}
) & {
/**
* Whether to create the page in the background.
*
* @defaultValue `false`
*/
background?: boolean;
};
/**
* @public
*/
export declare interface Credentials {
username: string;
password: string;
}
/**
* @public
*/
export declare class CSSCoverage {
#private;
constructor(client: CDPSession);
start(options?: {resetOnNavigation?: boolean}): Promise;
stop(): Promise;
}
/**
* Set of configurable options for CSS coverage.
* @public
*/
export declare interface CSSCoverageOptions {
/**
* Whether to reset coverage on every navigation.
*/
resetOnNavigation?: boolean;
}
/**
* @public
*/
export declare interface CustomQueryHandler {
/**
* Searches for a {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Node} matching the given `selector` from {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | node}.
*/
queryOne?: (node: Node, selector: string) => Node | null;
/**
* Searches for some {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Nodes} matching the given `selector` from {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | node}.
*/
queryAll?: (node: Node, selector: string) => Iterable;
}
/**
* @public
*/
declare interface CustomQuerySelector {
querySelector(root: Node, selector: string): Awaitable;
querySelectorAll(root: Node, selector: string): AwaitableIterable;
}
/**
* This class mimics the injected {@link CustomQuerySelectorRegistry}.
*
*/
declare class CustomQuerySelectorRegistry {
#private;
register(name: string, handler: CustomQueryHandler): void;
unregister(name: string): void;
get(name: string): CustomQuerySelector | undefined;
clear(): void;
}
declare namespace CustomQuerySelectors {
export type {CustomQuerySelector};
export {CustomQuerySelectorRegistry};
}
/**
* @public
* @experimental
*/
export declare interface DebugInfo {
pendingProtocolErrors: Error[];
}
/**
* The default cooperative request interception resolution priority
*
* @public
*/
export declare const DEFAULT_INTERCEPT_RESOLUTION_PRIORITY = 0;
/**
* @public
*/
export declare const /**
* @public
*/
/**
* @public
*/
defaultArgs: (options?: Puppeteer_2.LaunchOptions) => Promise;
/**
* @public
*/
export declare interface DeleteCookiesRequest {
/**
* Name of the cookies to remove.
*/
name: string;
/**
* If specified, deletes all the cookies with the given name where domain and path match
* provided URL. Otherwise, deletes only cookies related to the current page's domain.
*/
url?: string;
/**
* If specified, deletes only cookies with the exact domain.
*/
domain?: string;
/**
* If specified, deletes only cookies with the exact path.
*/
path?: string;
/**
* If specified, deletes cookies in the given partition key. In
* Chrome, partitionKey matches the top-level site the partitioned
* cookie is available in.
* In Firefox, it matches the source origin in the
* {@link https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey | PartitionKey }.
*/
partitionKey?: CookiePartitionKey | string;
}
/**
* @public
*/
export declare interface Device {
userAgent: string;
viewport: Viewport;
}
/**
* Device request prompts let you respond to the page requesting for a device
* through an API like WebBluetooth.
*
* @remarks
* `DeviceRequestPrompt` instances are returned via the
* {@link Page.waitForDevicePrompt} method.
*
* @example
*
* ```ts
* const [devicePrompt] = Promise.all([
* page.waitForDevicePrompt(),
* page.click('#connect-bluetooth'),
* ]);
* await devicePrompt.select(
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
* );
* ```
*
* @public
*/
export declare abstract class DeviceRequestPrompt {
/**
* Current list of selectable devices.
*/
readonly devices: DeviceRequestPromptDevice[];
/**
* Resolve to the first device in the prompt matching a filter.
*/
abstract waitForDevice(
filter: (device: DeviceRequestPromptDevice) => boolean,
options?: WaitTimeoutOptions,
): Promise;
/**
* Select a device in the prompt's list.
*/
abstract select(device: DeviceRequestPromptDevice): Promise;
/**
* Cancel the prompt.
*/
abstract cancel(): Promise;
}
/**
* Device in a request prompt.
*
* @public
*/
export declare interface DeviceRequestPromptDevice {
/**
* Device id during a prompt.
*/
id: string;
/**
* Device name as it appears in a prompt.
*/
name: string;
}
/**
* Dialog instances are dispatched by the {@link Page} via the `dialog` event.
*
* @remarks
*
* @example
*
* ```ts
* import puppeteer from 'puppeteer';
*
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* page.on('dialog', async dialog => {
* console.log(dialog.message());
* await dialog.dismiss();
* await browser.close();
* });
* await page.evaluate(() => alert('1'));
* ```
*
* @public
*/
export declare abstract class Dialog {
#private;
/**
* The type of the dialog.
*/
type(): Protocol.Page.DialogType;
/**
* The message displayed in the dialog.
*/
message(): string;
/**
* The default value of the prompt, or an empty string if the dialog
* is not a `prompt`.
*/
defaultValue(): string;
/**
* A promise that resolves when the dialog has been accepted.
*
* @param promptText - optional text that will be entered in the dialog
* prompt. Has no effect if the dialog's type is not `prompt`.
*
*/
accept(promptText?: string): Promise;
/**
* A promise which will resolve once the dialog has been dismissed
*/
dismiss(): Promise;
}
/**
* @public
*/
export declare interface DownloadBehavior {
/**
* Whether to allow all or deny all download requests, or use default behavior if
* available.
*
* @remarks
* Setting this to `allowAndName` will name all files according to their download guids.
*/
policy: DownloadPolicy;
/**
* The default path to save downloaded files to.
*
* @remarks
* Setting this is required if behavior is set to `allow` or `allowAndName`.
*/
downloadPath?: string;
}
/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @public
*/
export declare type DownloadPolicy =
'deny' | 'allow' | 'allowAndName' | 'default';
/**
* @public
*/
export declare type ElementFor<
TagName extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap,
> = TagName extends keyof HTMLElementTagNameMap
? HTMLElementTagNameMap[TagName]
: TagName extends keyof SVGElementTagNameMap
? SVGElementTagNameMap[TagName]
: never;
/**
* ElementHandle represents an in-page DOM element.
*
* @remarks
* ElementHandles can be created with the {@link Page.$} method.
*
* ```ts
* import puppeteer from 'puppeteer';
*
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.goto('https://example.com');
* const hrefElement = await page.$('a');
* await hrefElement.click();
* // ...
* ```
*
* ElementHandle prevents the DOM element from being garbage-collected unless the
* handle is {@link JSHandle.dispose | disposed}. ElementHandles are auto-disposed
* when their associated frame is navigated away or the parent
* context gets destroyed.
*
* ElementHandle instances can be used as arguments in {@link Page.$eval} and
* {@link Page.evaluate} methods.
*
* If you're using TypeScript, ElementHandle takes a generic argument that
* denotes the type of element the handle is holding within. For example, if you
* have a handle to a `` element, you can type it as
* `ElementHandle` and you get some nicer type checks.
*
* @public
*/
export declare abstract class ElementHandle<
ElementType extends Node = Element,
> extends JSHandle {
#private;
/**
* Frame corresponding to the current handle.
*/
abstract get frame(): Frame;
/**
* Queries the current element for an element matching the given selector.
*
* @param selector -
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
* to query the page for.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
* can be passed as-is and a
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
* allows querying by
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
* and
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
* and
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
* Alternatively, you can specify the selector type using a
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
* @returns A {@link ElementHandle | element handle} to the first element
* matching the given selector. Otherwise, `null`.
*/
$(
selector: Selector,
): Promise> | null>;
/**
* Queries the current element for all elements matching the given selector.
*
* @param selector -
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
* to query the page for.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
* can be passed as-is and a
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
* allows querying by
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
* and
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
* and
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
* Alternatively, you can specify the selector type using a
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
* @returns An array of {@link ElementHandle | element handles} that point to
* elements matching the given selector.
*/
$$(
selector: Selector,
options?: QueryOptions,
): Promise>>>;
/**
* Runs the given function on the first element matching the given selector in
* the current element.
*
* If the given function returns a promise, then this method will wait till
* the promise resolves.
*
* @example
*
* ```ts
* const tweetHandle = await page.$('.tweet');
* expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe(
* '100',
* );
* expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe(
* '10',
* );
* ```
*
* @param selector -
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
* to query the page for.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
* can be passed as-is and a
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
* allows querying by
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
* and
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
* and
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
* Alternatively, you can specify the selector type using a
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
* @param pageFunction - The function to be evaluated in this element's page's
* context. The first element matching the selector will be passed in as the
* first argument.
* @param args - Additional arguments to pass to `pageFunction`.
* @returns A promise to the result of the function.
*/
$eval<
Selector extends string,
Params extends unknown[],
Func extends EvaluateFuncWith, Params> = EvaluateFuncWith<
NodeFor,
Params
>,
>(
selector: Selector,
pageFunction: Func | string,
...args: Params
): Promise>>;
/**
* Runs the given function on an array of elements matching the given selector
* in the current element.
*
* If the given function returns a promise, then this method will wait till
* the promise resolves.
*
* @example
* HTML:
*
* ```html
*
*
*
*
* ```
*
* JavaScript:
*
* ```ts
* const feedHandle = await page.$('.feed');
*
* const listOfTweets = await feedHandle.$$eval('.tweet', nodes =>
* nodes.map(n => n.innerText),
* );
* ```
*
* @param selector -
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
* to query the page for.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
* can be passed as-is and a
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
* allows querying by
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
* and
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
* and
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
* Alternatively, you can specify the selector type using a
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
* @param pageFunction - The function to be evaluated in the element's page's
* context. An array of elements matching the given selector will be passed to
* the function as its first argument.
* @param args - Additional arguments to pass to `pageFunction`.
* @returns A promise to the result of the function.
*/
$$eval<
Selector extends string,
Params extends unknown[],
Func extends EvaluateFuncWith>, Params> =
EvaluateFuncWith>, Params>,
>(
selector: Selector,
pageFunction: Func | string,
...args: Params
): Promise>>;
/**
* Wait for an element matching the given selector to appear in the current
* element.
*
* Unlike {@link Frame.waitForSelector}, this method does not work across
* navigations or if the element is detached from DOM.
*
* @example
*
* ```ts
* import puppeteer from 'puppeteer';
*
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* let currentURL;
* page
* .mainFrame()
* .waitForSelector('img')
* .then(() => console.log('First URL with image: ' + currentURL));
*
* for (currentURL of [
* 'https://example.com',
* 'https://google.com',
* 'https://bbc.com',
* ]) {
* await page.goto(currentURL);
* }
* await browser.close();
* ```
*
* @param selector - The selector to query and wait for.
* @param options - Options for customizing waiting behavior.
* @returns An element matching the given selector.
* @throws Throws if an element matching the given selector doesn't appear.
*/
waitForSelector(
selector: Selector,
options?: WaitForSelectorOptions,
): Promise> | null>;
/**
* An element is considered to be visible if all of the following is
* true:
*
* - the element has
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
*
* - the element has a non-empty
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
*
* - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
* is not `hidden` or `collapse`.
*/
isVisible(): Promise;
/**
* An element is considered to be hidden if at least one of the following is true:
*
* - the element has no
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
*
* - the element has an empty
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
*
* - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
* is `hidden` or `collapse`.
*/
isHidden(): Promise;
/**
* Converts the current handle to the given element type.
*
* @example
*
* ```ts
* const element: ElementHandle = await page.$(
* '.class-name-of-anchor',
* );
* // DO NOT DISPOSE `element`, this will be always be the same handle.
* const anchor: ElementHandle =
* await element.toElement('a');
* ```
*
* @param tagName - The tag name of the desired element type.
* @throws An error if the handle does not match. **The handle will not be
* automatically disposed.**
*/
toElement(
tagName: K,
): Promise>>;
/**
* Resolves the frame associated with the element, if any. Always exists for
* HTMLIFrameElements.
*/
abstract contentFrame(this: ElementHandle): Promise ;
abstract contentFrame(): Promise ;
/**
* Returns the middle point within an element unless a specific offset is provided.
*/
clickablePoint(offset?: Offset): Promise;
/**
* This method scrolls element into view if needed, and then
* uses {@link Page.mouse} to hover over the center of the element.
* If the element is detached from DOM, the method throws an error.
*/
hover(this: ElementHandle): Promise;
/**
* This method scrolls element into view if needed, and then
* uses {@link Page.mouse} to click in the center of the element.
* If the element is detached from DOM, the method throws an error.
*/
click(
this: ElementHandle,
options?: Readonly,
): Promise;
/**
* Drags an element over the given element or point.
*
* @returns DEPRECATED. When drag interception is enabled, the drag payload is
* returned.
*/
drag(
this: ElementHandle,
target: Point | ElementHandle,
): Promise;
/**
* @deprecated Do not use. `dragenter` will automatically be performed during dragging.
*/
dragEnter(
this: ElementHandle,
data?: Protocol.Input.DragData,
): Promise;
/**
* @deprecated Do not use. `dragover` will automatically be performed during dragging.
*/
dragOver(
this: ElementHandle,
data?: Protocol.Input.DragData,
): Promise;
/**
* Drops the given element onto the current one.
*/
drop(
this: ElementHandle,
element: ElementHandle,
): Promise;
/**
* @deprecated No longer supported.
*/
drop(
this: ElementHandle,
data?: Protocol.Input.DragData,
): Promise;
/**
* @deprecated Use `ElementHandle.drop` instead.
*/
dragAndDrop(
this: ElementHandle,
target: ElementHandle,
options?: {
delay: number;
},
): Promise;
/**
* Triggers a `change` and `input` event once all the provided options have been
* selected. If there's no `` element matching `selector`, the method
* throws an error.
*
* @example
*
* ```ts
* handle.select('blue'); // single selection
* handle.select('red', 'green', 'blue'); // multiple selections
* ```
*
* @param values - Values of options to select. If the `` has the
* `multiple` attribute, all values are considered, otherwise only the first
* one is taken into account.
*/
select(...values: string[]): Promise;
/**
* Sets the value of an
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input | input element}
* to the given file paths.
*
* @remarks This will not validate whether the file paths exists. Also, if a
* path is relative, then it is resolved against the
* {@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.
*/
abstract uploadFile(
this: ElementHandle,
...paths: string[]
): Promise;
/**
* This method scrolls element into view if needed, and then uses
* {@link Touchscreen.tap} to tap in the center of the element.
* If the element is detached from DOM, the method throws an error.
*/
tap(this: ElementHandle): Promise;
/**
* This method scrolls the element into view if needed, and then
* starts a touch in the center of the element.
* @returns A {@link TouchHandle} representing the touch that was started
*/
touchStart(this: ElementHandle): Promise;
/**
* This method scrolls the element into view if needed, and then
* moves the touch to the center of the element.
* @param touch - An optional {@link TouchHandle}. If provided, this touch
* will be moved. If not provided, the first active touch will be moved.
*/
touchMove(this: ElementHandle, touch?: TouchHandle): Promise;
touchEnd(this: ElementHandle): Promise;
/**
* Calls {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus | focus} on the element.
*/
focus(): Promise;
/**
* Focuses the element, and then sends a `keydown`, `keypress`/`input`, and
* `keyup` event for each character in the text.
*
* To press a special key, like `Control` or `ArrowDown`,
* use {@link ElementHandle.press}.
*
* @example
*
* ```ts
* await elementHandle.type('Hello'); // Types instantly
* await elementHandle.type('World', {delay: 100}); // Types slower, like a user
* ```
*
* @example
* An example of typing into a text field and then submitting the form:
*
* ```ts
* const elementHandle = await page.$('input');
* await elementHandle.type('some text');
* await elementHandle.press('Enter');
* ```
*
* @param options - Delay in milliseconds. Defaults to 0.
*/
type(text: string, options?: Readonly): Promise;
/**
* Focuses the element, and then uses {@link Keyboard.down} and {@link Keyboard.up}.
*
* @remarks
* If `key` is a single character and no modifier keys besides `Shift`
* are being held down, a `keypress`/`input` event will also be generated.
* The `text` option can be specified to force an input event to be generated.
*
* **NOTE** Modifier keys DO affect `elementHandle.press`. Holding down `Shift`
* will type the text in upper case.
*
* @param key - Name of key to press, such as `ArrowLeft`.
* See {@link KeyInput} for a list of all key names.
*/
press(key: KeyInput, options?: Readonly): Promise;
/**
* This method returns the bounding box of the element (relative to the main frame),
* or `null` if the element is {@link https://drafts.csswg.org/css-display-4/#box-generation | not part of the layout}
* (example: `display: none`).
*/
boundingBox(): Promise;
/**
* This method returns boxes of the element,
* or `null` if the element is {@link https://drafts.csswg.org/css-display-4/#box-generation | not part of the layout}
* (example: `display: none`).
*
* @remarks
*
* Boxes are represented as an array of points;
* Each Point is an object `{x, y}`. Box points are sorted clock-wise.
*/
boxModel(): Promise;
/**
* This method scrolls element into view if needed, and then uses
* {@link Page.(screenshot:2) } to take a screenshot of the element.
* If the element is detached from DOM, the method throws an error.
*/
screenshot(
options: Readonly & {
encoding: 'base64';
},
): Promise;
screenshot(options?: Readonly): Promise;
/**
* Resolves to true if the element is visible in the current viewport. If an
* element is an SVG, we check if the svg owner element is in the viewport
* instead. See https://crbug.com/963246.
*
* @param options - Threshold for the intersection between 0 (no intersection) and 1
* (full intersection). Defaults to 1.
*/
isIntersectingViewport(
this: ElementHandle,
options?: {
threshold?: number;
},
): Promise;
/**
* Scrolls the element into view using either the automation protocol client
* or by calling element.scrollIntoView.
*/
scrollIntoView(this: ElementHandle): Promise;
/**
* Creates a locator based on an ElementHandle. This would not allow
* refreshing the element handle if it is stale but it allows re-using other
* locator pre-conditions.
*/
asLocator(this: ElementHandle): Locator;
/**
* If the element is a form input, you can use {@link ElementHandle.autofill}
* to test if the form is compatible with the browser's autofill
* implementation. Throws an error if the form cannot be autofilled.
*
* @remarks
*
* Currently, Puppeteer supports auto-filling credit card information only and
* in Chrome in the new headless and headful modes only.
*
* ```ts
* // Select an input on the credit card form.
* const name = await page.waitForSelector('form #name');
* // Trigger autofill with the desired data.
* await name.autofill({
* creditCard: {
* number: '4444444444444444',
* name: 'John Smith',
* expiryMonth: '01',
* expiryYear: '2030',
* cvc: '123',
* },
* });
* ```
*/
abstract autofill(data: AutofillData): Promise;
/**
* When connected using Chrome DevTools Protocol, it returns a
* DOM.BackendNodeId for the element.
*/
abstract backendNodeId(): Promise;
}
/**
* @public
*/
export declare interface ElementScreenshotOptions extends ScreenshotOptions {
/**
* @defaultValue `true`
*/
scrollIntoView?: boolean;
}
/**
* @public
*/
export declare type ErrorCode =
| 'aborted'
| 'accessdenied'
| 'addressunreachable'
| 'blockedbyclient'
| 'blockedbyresponse'
| 'connectionaborted'
| 'connectionclosed'
| 'connectionfailed'
| 'connectionrefused'
| 'connectionreset'
| 'internetdisconnected'
| 'namenotresolved'
| 'timedout'
| 'failed';
/**
* @public
*/
export declare type EvaluateFunc = (
...params: InnerParams
) => Awaitable;
/**
* @public
*/
export declare type EvaluateFuncWith = (
...params: [V, ...InnerParams]
) => Awaitable;
/**
* The EventEmitter class that many Puppeteer classes extend.
*
* @remarks
*
* This allows you to listen to events that Puppeteer classes fire and act
* accordingly. Therefore you'll mostly use {@link EventEmitter.on | on} and
* {@link EventEmitter.off | off} to bind
* and unbind to event listeners.
*
* @public
*/
export declare class EventEmitter<
Events extends Record,
> implements CommonEventEmitter> {
#private;
/**
* Bind an event listener to fire when an event occurs.
* @param type - the event type you'd like to listen to. Can be a string or symbol.
* @param handler - the function to be called when the event occurs.
* @returns `this` to enable you to chain method calls.
*/
on>(
type: Key,
handler: Handler[Key]>,
): this;
/**
* Remove an event listener from firing.
* @param type - the event type you'd like to stop listening to.
* @param handler - the function that should be removed.
* @returns `this` to enable you to chain method calls.
*/
off>(
type: Key,
handler?: Handler[Key]>,
): this;
/**
* Emit an event and call any associated listeners.
*
* @param type - the event you'd like to emit
* @param eventData - any data you'd like to emit with the event
* @returns `true` if there are any listeners, `false` if there are not.
*/
emit>(
type: Key,
event: EventsWithWildcard[Key],
): boolean;
/**
* Like `on` but the listener will only be fired once and then it will be removed.
* @param type - the event you'd like to listen to
* @param handler - the handler function to run when the event occurs
* @returns `this` to enable you to chain method calls.
*/
once>(
type: Key,
handler: Handler[Key]>,
): this;
/**
* Gets the number of listeners for a given event.
*
* @param type - the event to get the listener count for
* @returns the number of listeners bound to the given event
*/
listenerCount(type: keyof EventsWithWildcard): number;
/**
* Removes all listeners. If given an event argument, it will remove only
* listeners for that event.
*
* @param type - the event to remove listeners for.
* @returns `this` to enable you to chain method calls.
*/
removeAllListeners(type?: keyof EventsWithWildcard): this;
}
/**
* @public
*/
export declare type EventsWithWildcard<
Events extends Record,
> = Events & {
'*': Events[keyof Events];
};
/**
* @public
*/
export declare type EventType = string | symbol;
/**
* @public
*/
export declare const /**
* @public
*/
/**
* @public
*/
executablePath: {
(channel: Puppeteer_2.ChromeReleaseChannel): Promise;
(options: Puppeteer_2.LaunchOptions): Promise;
(): Promise;
};
/**
* Defines experiment options for Puppeteer.
*
* See individual properties for more information.
*
* @public
*/
export declare type ExperimentsConfiguration = Record;
/**
* {@link Extension} represents a browser extension installed in the browser.
* It provides access to the extension's ID, name, and version, as well as
* methods for interacting with the extension's background workers and pages.
*
* @example
* To get all extensions installed in the browser:
*
* ```ts
* const extensions = await browser.extensions();
* for (const [id, extension] of extensions) {
* console.log(extension.name, id);
* }
* ```
*
* @experimental
* @public
*/
export declare abstract class Extension {
#private;
/**
* Whether the extension is enabled.
*
* @public
*/
get enabled(): boolean;
/**
* The path in the file system where the extension is located.
*
* @public
*/
get path(): string;
/**
* The version of the extension as specified in its manifest.
*
* @public
*/
get version(): string;
/**
* The name of the extension as specified in its manifest.
*
* @public
*/
get name(): string;
/**
* The unique identifier of the extension.
*
* @public
*/
get id(): string;
/**
* Returns a list of the currently active service workers belonging
* to the extension.
*
* @public
*/
abstract workers(): Promise;
/**
* Returns a list of the currently active and visible pages belonging
* to the extension.
*
* @public
*/
abstract pages(): Promise;
/**
* Triggers the default action of the extension for a specified page.
* This typically simulates a user clicking the extension's action icon
* in the browser toolbar, potentially opening a popup or executing an action script.
*
* @param page - The page to trigger the action on.
* @public
*/
abstract triggerAction(page: Page): Promise;
}
/**
* @public
*/
export declare interface ExtensionInstallOptions {
/**
* Whether to enable the extension in Incognito or OTR profiles in Chrome.
*/
enabledInIncognito: boolean;
}
/**
* Experimental ExtensionTransport allows establishing a connection via
* chrome.debugger API if Puppeteer runs in an extension. Since Chrome
* DevTools Protocol is restricted for extensions, the transport
* implements missing commands and events.
*
* @experimental
* @public
*/
export declare class ExtensionTransport implements ConnectionTransport {
#private;
static connectTab(tabId: number): Promise;
onmessage?: (message: string) => void;
onclose?: () => void;
send(message: string): void;
close(): void;
}
/**
* File choosers let you react to the page requesting for a file.
*
* @remarks
* `FileChooser` instances are returned via the {@link Page.waitForFileChooser} method.
*
* In browsers, only one file chooser can be opened at a time.
* All file choosers must be accepted or canceled. Not doing so will prevent
* subsequent file choosers from appearing.
*
* @example
*
* ```ts
* const [fileChooser] = await Promise.all([
* page.waitForFileChooser(),
* page.click('#upload-file-button'), // some button that triggers file selection
* ]);
* await fileChooser.accept(['/tmp/myfile.pdf']);
* ```
*
* @public
*/
export declare class FileChooser {
#private;
/**
* Whether file chooser allow for
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-multiple | multiple}
* file selection.
*/
isMultiple(): boolean;
/**
* Accept the file chooser request with the given file paths.
*
* @remarks This will not validate whether the file paths exists. Also, if a
* path is relative, then it is resolved against the
* {@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.
*/
accept(paths: string[]): Promise;
/**
* Closes the file chooser without selecting any files.
*/
cancel(): Promise;
}
/**
* @public
*/
export declare interface FirefoxSettings {
/**
* Tells Puppeteer to not download the browser during installation.
*
* Can be overridden by `PUPPETEER_FIREFOX_SKIP_DOWNLOAD`.
*
* @defaultValue true
*/
skipDownload?: boolean;
/**
* Specifies the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_FIREFOX_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*
* @defaultValue https://archive.mozilla.org/pub/firefox/releases
*/
downloadBaseUrl?: string;
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_FIREFOX_VERSION`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @example stable_129.0
* @defaultValue The pinned browser version supported by the current Puppeteer
* version.
*/
version?: string;
}
/**
* @public
*/
export declare type FlattenHandle = T extends HandleOr ? U : never;
/**
* Represents a DOM frame.
*
* To understand frames, you can think of frames as `