40 KiB
sidebar_label |
---|
API |
API Reference
Classes
Class |
Description |
---|---|
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 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 represents individual user contexts within a browser. When a browser is launched, it has a single browser context by default. 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: The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the | |
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 | |
ConsoleMessage objects are dispatched by page via the 'console' event. | |
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. | |
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 | |
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 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 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 | |
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 | |
(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 | |
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 | |
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 | |
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 | |
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 | |
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 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 | |
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. | |
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 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 | |
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 | |
ProtocolError is emitted whenever there is an error from the protocol. | |
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 | |
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 | |
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 | |
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 | |
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 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 is emitted whenever certain operations are terminated due to timeout. Remarks: Example operations are page.waitForSelector or puppeteer.launch. | |
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 | |
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 | |
Puppeteer will throw this error if a method is not supported by the currently used protocol | |
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 |
---|---|
All the events a browser instance may emit. | |
All the events that a locator instance may emit. | |
All the events that a page instance may emit. | |
Functions
Function |
Description |
---|---|
Deprecated: Import Puppeteer and use the static method Puppeteer.clearCustomQueryHandlers() | |
Deprecated: Import Puppeteer and use the static method Puppeteer.customQueryHandlerNames() | |
Deprecated: Import Puppeteer and use the static method Puppeteer.registerCustomQueryHandler() | |
Deprecated: Import Puppeteer and use the static method Puppeteer.unregisterCustomQueryHandler() |
Interfaces
Interface |
Description |
---|---|
Generic browser options that can be passed when launching any browser or when connecting to an existing browser instance. | |
Launcher options that only apply to Chrome. | |
Defines options to configure Puppeteer's behavior during installation and runtime. See individual properties for more information. | |
|
Represents a cookie object. |
|
Cookie parameter object |
The CoverageEntry class represents one entry of the coverage report. | |
Set of configurable options for CSS coverage. | |
(Experimental) | |
| |
The CoverageEntry class for JavaScript | |
Set of configurable options for JS coverage. | |
Generic launch options that can be passed when launching any browser. | |
A media feature to emulate. | |
Denotes the objects received by callback functions for page events. See PageEvent for more detail on the events and when they are emitted. | |
Valid options to configure PDF generation via Page.pdf(). | |
Required response data to fulfill a request with. | |
(Experimental) | |
Represents a Node and the properties of it that are relevant to Accessibility. | |
Namespaces
Namespace |
Description |
---|---|
Events that the CDPSession class emits. |
Variables
Variable |
Description |
---|---|
The default cooperative request interception resolution priority | |
A list of devices to be used with Page.emulate(). | |
|
Enum of valid mouse buttons. |
A list of pre-defined network conditions to be used with Page.emulateNetworkConditions(). | |
Type Aliases
Type Alias |
Description |
---|---|
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. |
Defines experiment options for Puppeteer. See individual properties for more information. | |
All the valid keys that can be passed to functions that take user input, such as keyboard.press | |
| |
All the valid paper format types when printing a PDF. Remarks: The sizes of each format are as follows:
| |
Supported products. | |
Utility type exposed to enable users to define options that can be passed to | |
Resource types for HTTPRequests as perceived by the rendering engine. | |