///
import type { ChildProcess } from 'child_process';
import { EventType } from 'mitt';
import { PassThrough } from 'stream';
import { Protocol } from 'devtools-protocol';
import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
import type { Readable } from 'stream';
/**
* 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;
/* Excluded from this release type: __constructor */
/* Excluded from this release type: updateClient */
/**
* 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;
}
/* Excluded from this release type: Action */
/**
* @public
*/
export declare interface ActionOptions {
signal?: AbortSignal;
}
/**
* @public
*/
export declare type ActionResult = 'continue' | 'abort' | 'respond';
/* Excluded from this release type: addPageBinding */
/* Excluded from this release type: ARIAQueryHandler */
/* Excluded from this release type: assert */
/* Excluded from this release type: AsyncDisposableStack */
/* Excluded from this release type: asyncDisposeSymbol */
/* Excluded from this release type: AsyncIterableUtil */
/**
* @public
*/
export declare interface AutofillData {
creditCard: {
number: string;
name: string;
expiryMonth: string;
expiryYear: string;
cvc: string;
};
}
/**
* @public
*/
export declare type Awaitable = T | PromiseLike;
/**
* @public
*/
export declare type AwaitableIterable = Iterable | AsyncIterable;
/* Excluded from this release type: AwaitableIterator */
/**
* @public
*/
export declare type AwaitedLocator = T extends Locator ? S : never;
declare type BeginSubclassSelectorTokens = ['.', '#', '[', ':'];
/* Excluded from this release type: BidiBrowser */
/* Excluded from this release type: BidiBrowserContext */
/* Excluded from this release type: BidiBrowserContextOptions */
/* Excluded from this release type: BidiBrowserOptions */
/* Excluded from this release type: BidiConnection */
/* Excluded from this release type: BidiEvents */
/* Excluded from this release type: BidiFrame */
/* Excluded from this release type: BidiHTTPRequest */
/* Excluded from this release type: BidiHTTPResponse */
/* Excluded from this release type: BidiJSHandle */
/* Excluded from this release type: BidiKeyboard */
/* Excluded from this release type: BidiMouse */
/* Excluded from this release type: BidiMouseClickOptions */
/* Excluded from this release type: BidiMouseMoveOptions */
/* Excluded from this release type: BidiNetworkManager */
/* Excluded from this release type: BidiPage */
/* Excluded from this release type: BidiRealm */
/* Excluded from this release type: BidiTarget */
/* Excluded from this release type: BidiTouchMoveOptions */
/* Excluded from this release type: BidiTouchscreen */
/* Excluded from this release type: Binding */
/* Excluded from this release type: BindingPayload */
/**
* @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 | 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.
* 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 {
/* Excluded from this release type: __constructor */
/* Excluded from this release type: _attach */
/* Excluded from this release type: _detach */
/**
* 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}.
*/
process(): ChildProcess | null;
/* Excluded from this release type: _getIsPageTargetCallback */
/**
* Creates a new incognito {@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 incognito browser context.
* const context = await browser.createIncognitoBrowserContext();
* // Create a new page in a pristine context.
* const page = await context.newPage();
* // Do stuff
* await page.goto('https://example.com');
* ```
*/
abstract createIncognitoBrowserContext(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;
/* Excluded from this release type: _disposeContext */
/**
* 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(): Promise;
/* Excluded from this release type: _createPageInContext */
/**
* 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 ar multiple {@link BrowserContext | browser contexts}, this
* returns all {@link Page | pages} in all
* {@link BrowserContext | browser contexts}.
*
* @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
* will not be listed here. You can find them using {@link Target.page}.
*/
pages(): 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}.
*/
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.
*/
disconnect(): void;
/**
* Whether Puppeteer is connected to this {@link Browser | browser}.
*
* @deprecated Use {@link Browser.connected}.
*/
isConnected(): boolean;
/**
* Whether Puppeteer is connected to this {@link Browser | browser}.
*/
abstract get connected(): boolean;
/* Excluded from this release type: [disposeSymbol] */
/* Excluded from this release type: [asyncDisposeSymbol] */
}
/* Excluded from this release type: BrowserCloseCallback */
/**
* Generic browser options that can be passed when launching any browser or when
* connecting to an existing browser instance.
* @public
*/
export declare interface BrowserConnectOptions {
/**
* Whether to ignore HTTPS errors during navigation.
* @defaultValue `false`
*/
ignoreHTTPSErrors?: boolean;
/**
* Sets the viewport for each page.
*/
defaultViewport?: Viewport | null;
/**
* 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;
/* Excluded from this release type: _isPageTarget */
/* Excluded from this release type: protocol */
/**
* Timeout setting for individual protocol (CDP) calls.
*
* @defaultValue `180_000`
*/
protocolTimeout?: number;
}
/**
* {@link BrowserContext} represents individual sessions within a
* {@link Browser | browser}.
*
* When a {@link Browser | browser} is launched, it has a single
* {@link BrowserContext | browser context} by default. Others can be created
* using {@link Browser.createIncognitoBrowserContext}.
*
* {@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 an incognito {@link BrowserContext | browser context}:
*
* ```ts
* // Create a new incognito browser context
* const context = await browser.createIncognitoBrowserContext();
* // 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();
* ```
*
* @public
*/
export declare abstract class BrowserContext extends EventEmitter {
/* Excluded from this release type: __constructor */
/**
* Gets all active {@link Target | targets} inside this
* {@link BrowserContext | browser context}.
*/
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/'
* );
* ```
*/
abstract waitForTarget(predicate: (x: Target) => boolean | Promise, options?: WaitForTargetOptions): Promise;
/**
* Gets a list of all open {@link Page | pages} inside this
* {@link BrowserContext | browser context}.
*
* @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(): Promise;
/**
* Whether this {@link BrowserContext | browser context} is incognito.
*
* The {@link Browser.defaultBrowserContext | default browser context} is the
* only non-incognito browser context.
*/
abstract isIncognito(): boolean;
/**
* 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.
*/
overridePermissions(origin: string, permissions: Permission[]): 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();
* ```
*/
clearPermissionOverrides(): Promise;
/**
* Creates a new {@link Page | page} in this
* {@link BrowserContext | browser context}.
*/
abstract newPage(): 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;
/**
* Whether this {@link BrowserContext | browser context} is closed.
*/
get closed(): boolean;
/**
* Identifier for this {@link BrowserContext | browser context}.
*/
get id(): string | undefined;
/* Excluded from this release type: [disposeSymbol] */
/* Excluded from this release type: [asyncDisposeSymbol] */
}
/**
* @public
*/
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"
}
export { BrowserContextEvent as BrowserContextEmittedEvents }
export { BrowserContextEvent }
/**
* @public
*/
export declare interface BrowserContextEvents extends Record {
[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[];
}
/**
* All the events a {@link Browser | browser instance} may emit.
*
* @public
*/
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 incognito 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 incognito 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 incognito browser
* contexts.
*/
TargetDestroyed = "targetdestroyed",
/* Excluded from this release type: TargetDiscovered */
}
export { BrowserEvent as BrowserEmittedEvents }
export { BrowserEvent }
/**
* @public
*/
export declare interface BrowserEvents extends Record {
[BrowserEvent.Disconnected]: undefined;
[BrowserEvent.TargetCreated]: Target;
[BrowserEvent.TargetDestroyed]: Target;
[BrowserEvent.TargetChanged]: Target;
/* Excluded from this release type: targetdiscovered */
}
/**
* Launcher options that only apply to Chrome.
*
* @public
*/
export declare interface BrowserLaunchArgumentOptions {
/**
* Whether to run the browser in headless mode.
*
* @remarks
* In the future `headless: true` will be equivalent to `headless: 'new'`.
* You can read more about the change {@link https://developer.chrome.com/articles/new-headless/ | here}.
* Consider opting in early by setting the value to `"new"`.
*
* @defaultValue `true`
*/
headless?: boolean | 'new';
/**
* Path to a user data directory.
* {@link https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/user_data_dir.md | see the Chromium docs}
* for more info.
*/
userDataDir?: string;
/**
* Whether to auto-open a DevTools panel for each tab. If this is set to
* `true`, then `headless` will be forced to `false`.
* @defaultValue `false`
*/
devtools?: boolean;
/**
* Specify the debugging port number to use
*/
debuggingPort?: number;
/**
* Additional command line arguments to pass to the browser instance.
*/
args?: string[];
}
/* Excluded from this release type: BrowserWebSocketTransport */
/* Excluded from this release type: BrowsingContext */
/* Excluded from this release type: Callback */
/* Excluded from this release type: CallbackRegistry */
/* Excluded from this release type: CdpBrowser */
/* Excluded from this release type: CdpBrowserContext */
/* Excluded from this release type: CdpCDPSession */
/* Excluded from this release type: CdpDialog */
/* Excluded from this release type: CdpElementHandle */
/**
* @public
*/
export declare type CDPEvents = {
[Property in keyof ProtocolMapping.Events]: ProtocolMapping.Events[Property][0];
};
/* Excluded from this release type: CdpFrame */
/* Excluded from this release type: CdpHTTPRequest */
/* Excluded from this release type: CdpHTTPResponse */
/* Excluded from this release type: CdpJSHandle */
/* Excluded from this release type: CdpKeyboard */
/* Excluded from this release type: CdpMouse */
/* Excluded from this release type: CdpPage */
/**
* 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.target().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 {
/* Excluded from this release type: __constructor */
connection(): Connection | undefined;
/* Excluded from this release type: parentSession */
send(method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType']): 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.
*/
detach(): Promise;
/**
* Returns the session's id.
*/
id(): string;
}
/**
* Events that the CDPSession class emits.
*
* @public
*/
export declare namespace CDPSessionEvent {
/* Excluded from this release type: Disconnected */
/* Excluded from this release type: Swapped */
/* Excluded from this release type: Ready */
const SessionAttached: "sessionattached";
const SessionDetached: "sessiondetached";
}
/**
* @public
*/
export declare interface CDPSessionEvents extends CDPEvents, Record {
/* Excluded from this release type: [CDPSessionEvent.Disconnected] */
/* Excluded from this release type: [CDPSessionEvent.Swapped] */
/* Excluded from this release type: [CDPSessionEvent.Ready] */
[CDPSessionEvent.SessionAttached]: CDPSession;
[CDPSessionEvent.SessionDetached]: CDPSession;
}
/* Excluded from this release type: CdpTarget */
/* Excluded from this release type: CdpTouchscreen */
/* Excluded from this release type: ChromeLauncher */
/**
* @public
*/
export declare type ChromeReleaseChannel = 'chrome' | 'chrome-beta' | 'chrome-canary' | 'chrome-dev';
/* Excluded from this release type: ChromeTargetManager */
/**
* @deprecated Import {@link Puppeteer} and use the static method
* {@link Puppeteer.clearCustomQueryHandlers}
*
* @public
*/
export declare function clearCustomQueryHandlers(): void;
/**
* @public
*/
export declare interface ClickOptions extends MouseClickOptions {
/**
* Offset for the clickable point relative to the top-left corner of the border box.
*/
offset?: Offset;
}
/* Excluded from this release type: ClientProvider */
declare type CombinatorTokens = [' ', '>', '+', '~', '|', '|'];
/* Excluded from this release type: Commands */
/**
* @public
*/
export declare interface CommonEventEmitter> {
on(type: Key, handler: Handler): this;
off(type: Key, handler?: Handler): this;
emit(type: Key, event: Events[Key]): boolean;
addListener(type: Key, handler: Handler): this;
removeListener(type: Key, handler: Handler): this;
once(type: Key, handler: Handler): this;
listenerCount(event: keyof Events): number;
removeAllListeners(event?: keyof Events): this;
}
/* Excluded from this release type: CommonPuppeteerSettings */
declare type CompoundSelectorsOfComplexSelector = SplitWithDelemiters extends infer IntermediateTokens ? IntermediateTokens extends readonly string[] ? Drop : never : never;
/**
* Defines options to configure Puppeteer's behavior during installation and
* runtime.
*
* See individual properties for more information.
*
* @public
*/
export declare interface Configuration {
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_BROWSER_REVISION`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @defaultValue A compatible-revision of the browser.
*/
browserRevision?: string;
/**
* 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 the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
*
* @defaultValue Either https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing or
* https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central,
* depending on the product.
*/
downloadBaseUrl?: string;
/**
* Specifies the path for the downloads folder.
*
* Can be overridden by `PUPPETEER_DOWNLOAD_PATH`.
*
* @defaultValue ``
*/
downloadPath?: 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_PRODUCT`.
*
* @defaultValue `chrome`
*/
defaultProduct?: Product;
/**
* 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 during installation.
*
* Can be overridden by `PUPPETEER_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;
}
/**
* @public
*/
export declare const
/**
* @public
*/
/**
* @public
*/
connect: (options: ConnectOptions) => Promise;
/**
* @public
*/
export declare class Connection extends EventEmitter {
#private;
constructor(url: string, transport: ConnectionTransport, delay?: number, timeout?: number);
static fromSession(session: CDPSession): Connection | undefined;
get timeout(): number;
/* Excluded from this release type: _closed */
/* Excluded from this release type: _sessions */
/**
* @param sessionId - The session id
* @returns The current CDP session if it exists
*/
session(sessionId: string): CDPSession | null;
url(): string;
send(method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType']): Promise;
/* Excluded from this release type: _rawSend */
/* Excluded from this release type: closeBrowser */
/* Excluded from this release type: onMessage */
dispose(): void;
/* Excluded from this release type: isAutoAttached */
/* Excluded from this release type: _createSession */
/**
* @param targetInfo - The target info
* @returns The CDP session that is created
*/
createSession(targetInfo: Protocol.Target.TargetInfo): Promise;
}
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @public
*/
export declare interface ConnectionTransport {
send(message: string): void;
close(): void;
onmessage?: (message: string) => void;
onclose?: () => void;
}
/**
* @public
*/
export declare interface ConnectOptions extends BrowserConnectOptions {
browserWSEndpoint?: string;
browserURL?: string;
transport?: ConnectionTransport;
/**
* Headers to use for the web socket connection.
* @remarks
* Only works in the Node.js environment.
*/
headers?: Record;
}
/* Excluded from this release type: _connectToCdpBrowser */
/* Excluded from this release type: ConsoleAPICalledCallback */
/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
export declare class ConsoleMessage {
#private;
/**
* @public
*/
constructor(type: ConsoleMessageType, text: string, args: JSHandle[], stackTraceLocations: ConsoleMessageLocation[]);
/**
* 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' | 'warning' | '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;
}
/**
* 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;
constructor(client: CDPSession);
/* Excluded from this release type: updateClient */
/**
* @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;
}>;
}
/* Excluded from this release type: createCdpHandle */
/* Excluded from this release type: createClientError */
/* Excluded from this release type: createDebuggableDeferred */
/* Excluded from this release type: createEvaluationError */
/* Excluded from this release type: createProtocolErrorMessage */
/**
* @public
*/
export declare interface Credentials {
username: string;
password: string;
}
/**
* @public
*/
export declare class CSSCoverage {
#private;
constructor(client: CDPSession);
/* Excluded from this release type: updateClient */
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;
}
/**
* Copyright 2018 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @deprecated Do not use.
*
* @public
*/
export declare class CustomError extends Error {
/* Excluded from this release type: __constructor */
/* Excluded from this release type: [Symbol.toStringTag] */
}
/**
* @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;
}
/**
* @deprecated Import {@link Puppeteer} and use the static method
* {@link Puppeteer.customQueryHandlerNames}
*
* @public
*/
export declare function customQueryHandlerNames(): string[];
/* Excluded from this release type: CustomQueryHandlerRegistry */
/* Excluded from this release type: customQueryHandlers */
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 {
CustomQuerySelector,
customQuerySelectors
}
}
declare const customQuerySelectors: CustomQuerySelectorRegistry;
/* Excluded from this release type: debug_2 */
/* Excluded from this release type: debugError */
/**
* The default cooperative request interception resolution priority
*
* @public
*/
export declare const DEFAULT_INTERCEPT_RESOLUTION_PRIORITY = 0;
/**
* @public
*/
export declare const
/**
* @public
*/
/**
* @public
*/
defaultArgs: (options?: BrowserLaunchArgumentOptions | undefined) => string[];
/* Excluded from this release type: Deferred */
/* Excluded from this release type: DeferredOptions */
/* Excluded from this release type: DelegatedLocator */
/**
* @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 [deviceRequest] = Promise.all([
* page.waitForDevicePrompt(),
* page.click('#connect-bluetooth'),
* ]);
* await devicePrompt.select(
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
* );
* ```
*
* @public
*/
export declare class DeviceRequestPrompt {
#private;
/**
* Current list of selectable devices.
*/
devices: DeviceRequestPromptDevice[];
/* Excluded from this release type: __constructor */
/**
* Resolve to the first device in the prompt matching a filter.
*/
waitForDevice(filter: (device: DeviceRequestPromptDevice) => boolean, options?: WaitTimeoutOptions): Promise;
/**
* Select a device in the prompt's list.
*/
select(device: DeviceRequestPromptDevice): Promise;
/**
* Cancel the prompt.
*/
cancel(): Promise;
}
/**
* Device in a request prompt.
*
* @public
*/
export declare class DeviceRequestPromptDevice {
/**
* Device id during a prompt.
*/
id: string;
/**
* Device name as it appears in a prompt.
*/
name: string;
/* Excluded from this release type: __constructor */
}
/* Excluded from this release type: DeviceRequestPromptManager */
/**
* @deprecated Import {@link KnownDevices}
*
* @public
*/
export declare const devices: Readonly>;
/* Excluded from this release type: DevToolsTarget */
/**
* Dialog instances are dispatched by the {@link Page} via the `dialog` event.
*
* @remarks
*
* @example
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* 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();
* });
* page.evaluate(() => alert('1'));
* })();
* ```
*
* @public
*/
export declare abstract class Dialog {
#private;
/* Excluded from this release type: __constructor */
/**
* 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;
/* Excluded from this release type: sendCommand */
/**
* 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;
}
/* Excluded from this release type: DisposableStack */
/* Excluded from this release type: Disposed */
/* Excluded from this release type: disposeSymbol */
declare type Drop = Arr extends [infer Head, ...infer Tail] ? Head extends Remove ? Drop : Drop : Acc;
/**
* @public
*/
export declare type ElementFor = 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';
*
* (async () => {
* 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 origin frame gets navigated.
*
* 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 `