API Reference
Classes
Class | Description |
---|---|
Accessibility | The Accessibility class provides methods for inspecting the browser's accessibility tree. The accessibility tree is used by assistive technology such as screen readers or 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. The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Browser | Browser represents a browser instance that is either:
Browser emits various events which are documented in the BrowserEvent enum. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
BrowserContext | BrowserContext represents individual user contexts within a browser. When a browser is launched, it has at least one default browser context. Others can be created using Browser.createBrowserContext(). Each context has isolated storage (cookies/localStorage/etc.) BrowserContext emits various events which are documented in the BrowserContextEvent enum. If a page opens another page, e.g. using Remarks: In Chrome all non-default contexts are incognito, and default browser context might be incognito if you provide the The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
BrowserLauncher | Describes a launcher - a class that is able to create and launch a browser instance. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
CDPSession | The Remarks: Protocol methods can be called with CDPSession.send() method and protocol events can be subscribed to with Useful links: DevTools Protocol Viewer and Getting Started with DevTools Protocol. The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Connection | |
ConsoleMessage | ConsoleMessage objects are dispatched by page via the 'console' event. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Coverage | 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 Istanbul, see puppeteer-to-istanbul. The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
CSSCoverage | |
DeviceRequestPrompt | Device request prompts let you respond to the page requesting for a device through an API like WebBluetooth. Remarks:
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
DeviceRequestPromptDevice | Device in a request prompt. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Dialog | Dialog instances are dispatched by the Page via the Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
ElementHandle | ElementHandle represents an in-page DOM element. Remarks: ElementHandles can be created with the Page.$() method.
ElementHandle prevents the DOM element from being garbage-collected unless the handle is disposed. ElementHandles are auto-disposed when their origin frame gets navigated. ElementHandle instances can be used as arguments in Page.$eval() and 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 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
EventEmitter | 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 on and off to bind and unbind to event listeners. The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
ExtensionTransport | (Experimental) 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. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
FileChooser | File choosers let you react to the page requesting for a file. Remarks:
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. The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Frame | Represents a DOM frame. To understand frames, you can think of frames as Remarks: Frame lifecycles are controlled by three events that are all dispatched on the parent page: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
HTTPRequest | Represents an HTTP request sent by a page. Remarks: Whenever the page sends a request, such as for a network resource, the following events are emitted by Puppeteer's
If request fails at some point, then instead of All of these events provide an instance of
NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with If request gets a 'redirect' response, the request is successfully finished with the The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
HTTPResponse | The HTTPResponse class represents responses which are received by the Page class. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
JSCoverage | Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
JSHandle | Represents a reference to a JavaScript object. Instances can be created using Page.evaluateHandle(). Handles prevent the referenced JavaScript object from being garbage-collected unless the handle is purposely disposed. JSHandles are auto-disposed when their associated frame is navigated away or the parent context gets destroyed. Handles can be used as arguments for any evaluation function such as Page.$eval(), Page.evaluate(), and Page.evaluateHandle(). They are resolved to their referenced object. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Keyboard | Keyboard provides an api for managing a virtual keyboard. The high level api is Keyboard.type(), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page. Remarks: For finer control, you can use Keyboard.down(), Keyboard.up(), and Keyboard.sendCharacter() to manually fire events as if they were generated from a real keyboard. On macOS, keyboard shortcuts like The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Locator | Locators describe a strategy of locating objects and performing an action on them. If the action fails because the object is not ready for the action, the whole operation is retried. Various preconditions for a successful action are checked automatically. See https://pptr.dev/guides/page-interactions#locators for details. |
Mouse | The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Remarks: Every The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Page | Page provides methods to interact with a single tab or extension background page in the browser. note One Browser instance might have multiple Page instances. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
ProtocolError | ProtocolError is emitted whenever there is an error from the protocol. |
Puppeteer | The main Puppeteer class. IMPORTANT: if you are using Puppeteer in a Node environment, you will get an instance of PuppeteerNode when you import or require Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
PuppeteerError | The base class for all Puppeteer-specific errors Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
PuppeteerNode | Extends the main Puppeteer class with Node specific behaviour for fetching and downloading browsers. If you're using Puppeteer in a Node environment, this is the class you'll get when you run Remarks: The most common method to use is launch, which is used to launch and connect to a new browser instance. See the main Puppeteer class for methods common to all environments, such as Puppeteer.connect(). The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
ScreenRecorder | Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
SecurityDetails | The SecurityDetails class represents the security details of a response that was received over a secure connection. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Target | Target represents a CDP target. In CDP a target is something that can be debugged such a frame, a page or a worker. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
TimeoutError | TimeoutError is emitted whenever certain operations are terminated due to timeout. Remarks: Example operations are page.waitForSelector or puppeteer.launch. |
TouchError | TouchError is thrown when an attempt is made to move or end a touch that does not exist. |
Touchscreen | The Touchscreen class exposes touchscreen events. Remarks: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Tracing | The Tracing class exposes the tracing audit interface. Remarks: You can use The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
UnsupportedOperation | Puppeteer will throw this error if a method is not supported by the currently used protocol |
WebWorker | This class represents a WebWorker. Remarks: The events The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the |
Enumerations
Enumeration | Description |
---|---|
BrowserContextEvent | |
BrowserEvent | All the events a browser instance may emit. |
InterceptResolutionAction | |
LocatorEvent | All the events that a locator instance may emit. |
PageEvent | All the events that a page instance may emit. |
TargetType |
Functions
Function | Description |
---|---|
connect(options) | |
defaultArgs(options) | |
launch(options) | |
trimCache() |
Interfaces
Interface | Description |
---|---|
ActionOptions | |
AutofillData | |
BoundingBox | |
BoxModel | |
BrowserContextEvents | |
BrowserContextOptions | |
BrowserEvents | |
CDPSessionEvents | |
ChromeHeadlessShellSettings | |
ChromeSettings | |
ClickOptions | |
CommandOptions | |
CommonEventEmitter | |
Configuration | Defines options to configure Puppeteer's behavior during installation and runtime. See individual properties for more information. |
ConnectionTransport | |
ConnectOptions | Generic browser options that can be passed when launching any browser or when connecting to an existing browser instance. |
ConsoleMessageLocation | |
ContinueRequestOverrides | |
Represents a cookie object. | |
Cookie parameter object used to set cookies in the browser-level cookies API. | |
Cookie parameter object used to set cookies in the page-level cookies API. | |
Represents a cookie partition key in Chrome. | |
CoverageEntry | The CoverageEntry class represents one entry of the coverage report. |
Credentials | |
CSSCoverageOptions | Set of configurable options for CSS coverage. |
CustomQueryHandler | |
DebugInfo | (Experimental) |
Device | |
DownloadBehavior | |
ElementScreenshotOptions | |
FirefoxSettings | |
FrameAddScriptTagOptions | |
FrameAddStyleTagOptions | |
FrameEvents | |
FrameWaitForFunctionOptions | |
GeolocationOptions | |
GoToOptions | |
InterceptResolutionState | |
InternalNetworkConditions | |
JSCoverageEntry | The CoverageEntry class for JavaScript |
JSCoverageOptions | Set of configurable options for JS coverage. |
KeyboardTypeOptions | |
KeyDownOptions | |
LaunchOptions | Generic launch options that can be passed when launching any browser. |
LocatorEvents | |
LocatorScrollOptions | |
MediaFeature | A media feature to emulate. |
Metrics | |
MouseClickOptions | |
MouseMoveOptions | |
MouseOptions | |
MouseWheelOptions | |
Moveable | |
NetworkConditions | |
NewDocumentScriptEvaluation | |
Offset | |
PageEvents | Denotes the objects received by callback functions for page events. See PageEvent for more detail on the events and when they are emitted. |
PDFMargin | |
PDFOptions | Valid options to configure PDF generation via Page.pdf(). |
Point | |
QueryOptions | |
RemoteAddress | |
ResponseForRequest | Required response data to fulfill a request with. |
ScreencastOptions | (Experimental) |
ScreenshotClip | |
ScreenshotOptions | |
SerializedAXNode | Represents a Node and the properties of it that are relevant to Accessibility. |
SnapshotOptions | |
SupportedWebDriverCapabilities | WebDriver BiDi capabilities that are not set by Puppeteer itself. |
TouchHandle | The TouchHandle interface exposes methods to manipulate touches that have been started |
TracingOptions | |
Viewport | |
WaitForNetworkIdleOptions | |
WaitForOptions | |
WaitForSelectorOptions | |
WaitForTargetOptions | |
WaitTimeoutOptions |
Namespaces
Namespace | Description |
---|---|
CDPSessionEvent | Events that the CDPSession class emits. |
Variables
Variable | Description |
---|---|
DEFAULT_INTERCEPT_RESOLUTION_PRIORITY | The default cooperative request interception resolution priority |
executablePath | |
KnownDevices | A list of devices to be used with Page.emulate(). |
Enum of valid mouse buttons. | |
PredefinedNetworkConditions | A list of pre-defined network conditions to be used with Page.emulateNetworkConditions(). |
puppeteer |
Type Aliases
Type Alias | Description |
---|---|
ActionResult | |
Awaitable | |
AwaitableIterable | |
AwaitablePredicate | |
AwaitedLocator | |
CDPEvents | |
ChromeReleaseChannel | |
ConsoleMessageType | The supported types for console messages. |
Represents the cookie's 'Priority' status: https://tools.ietf.org/html/draft-west-cookie-priority-00 | |
Represents the cookie's 'SameSite' status: https://tools.ietf.org/html/draft-west-first-party-cookies | |
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. | |
DownloadPolicy | |
ElementFor | |
ErrorCode | |
EvaluateFunc | |
EvaluateFuncWith | |
EventsWithWildcard | |
EventType | |
ExperimentsConfiguration | Defines experiment options for Puppeteer. See individual properties for more information. |
FlattenHandle | |
HandleFor | |
HandleOr | |
Handler | |
InnerParams | |
KeyInput | All the valid keys that can be passed to functions that take user input, such as keyboard.press |
KeyPressOptions | |
LocatorClickOptions | |
LowerCasePaperFormat | |
Mapper | |
NodeFor | |
PaperFormat | All the valid paper format types when printing a PDF. Remarks: The sizes of each format are as follows:
|
Permission | |
Predicate | |
ProtocolLifeCycleEvent | |
ProtocolType | |
PuppeteerLifeCycleEvent | |
Quad | |
ResourceType | Resource types for HTTPRequests as perceived by the rendering engine. |
SupportedBrowser | Browsers supported by Puppeteer. |
SupportedWebDriverCapability | |
TargetFilterCallback | |
VisibilityOption | Whether to wait for the element to be visible or hidden. |