Skip to main content
Version: 24.38.0

API 参考

🌐 API Reference

🌐 Classes

🌐 Class

描述

🌐 Description

Accessibility

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.

附注

无障碍性是一个非常依赖平台的事情。在不同的平台上,可能有不同的屏幕阅读器,其输出可能差异很大。

🌐 Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might have wildly different output.

Blink——Chrome 的渲染引擎——有一个“可访问性树”的概念,然后将其转换为不同平台特定的 API。可访问性命名空间使用户能够访问 Blink 可访问性树。

🌐 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.

在从 Blink AX 树转换为特定平台的 AX 树或由辅助技术本身进行转换时,大部分可访问性树会被过滤掉。默认情况下,Puppeteer 会尝试近似这种过滤,只公开树中“有趣”的节点。

🌐 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.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Accessibility 类的子类。

🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Accessibility class.

Browser

浏览器 表示一个浏览器实例,该实例可以是:

浏览器 触发 各种事件,这些事件在 BrowserEvent 枚举中有文档记录。

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Browser 类的子类。

🌐 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 class.

BrowserContext

BrowserContext 表示 浏览器 中的单个用户上下文。

当启动一个浏览器时,它至少有一个默认的浏览器上下文。可以使用Browser.createBrowserContext()创建其他上下文。每个上下文都有独立的存储(cookies/localStorage/等)。

🌐 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 触发 各种事件,这些事件在 BrowserContextEvent 枚举中有记录。

如果一个页面打开另一个页面,例如使用window.open,弹出窗口将属于父页面的浏览器上下文

🌐 If a page opens another page, e.g. using window.open, the popup will belong to the parent page's browser context.

附注

在 Chrome 中,所有非默认上下文都是隐身模式,如果在启动浏览器时提供 --incognito 参数,默认浏览器上下文 也可能是隐身模式。

🌐 In Chrome all non-default contexts are incognito, and default browser context might be incognito if you provide the --incognito argument when launching the browser.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 BrowserContext 类的子类。

🌐 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 class.

BrowserLauncher

描述一个启动器——一个能够创建并启动浏览器实例的类。

🌐 Describes a launcher - a class that is able to create and launch a browser instance.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 BrowserLauncher 类的子类。

🌐 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 class.

CDPSession

CDPSession 实例用于直接与 Chrome Devtools 协议进行交互。

🌐 The CDPSession instances are used to talk raw Chrome Devtools Protocol.

附注

协议方法可以通过 CDPSession.send() 方法调用,协议事件可以通过 CDPSession.on 方法订阅。

🌐 Protocol methods can be called with CDPSession.send() method and protocol events can be subscribed to with CDPSession.on method.

有用的链接:DevTools 协议查看器DevTools 协议入门

🌐 Useful links: DevTools Protocol Viewer and Getting Started with DevTools Protocol.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 CDPSession 类的子类。

🌐 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 class.

Connection
ConnectionClosedError

如果底层协议连接已关闭,则抛出此异常。

🌐 Thrown if underlying protocol connection has been closed.

ConsoleMessage

ConsoleMessage 对象通过页面的 'console' 事件分发。

🌐 ConsoleMessage objects are dispatched by page via the 'console' event.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 ConsoleMessage 类的子类。

🌐 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 class.

Coverage

Coverage 类提供了收集有关页面所使用的 JavaScript 和 CSS 部分的信息的方法。

🌐 The Coverage class provides methods to gather information about parts of JavaScript and CSS that were used by the page.

附注

要以 Istanbul 可使用的格式输出覆盖率,请参阅 puppeteer-to-istanbul

🌐 To output coverage in a form consumable by Istanbul, see puppeteer-to-istanbul.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Coverage 类的子类。

🌐 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 class.

CSSCoverage
DeviceRequestPrompt

设备请求提示可让你通过 WebBluetooth 等 API 响应请求设备的页面。

🌐 Device request prompts let you respond to the page requesting for a device through an API like WebBluetooth.

附注

DeviceRequestPrompt 实例是通过 Page.waitForDevicePrompt() 方法返回的。

Dialog

对话实例通过 dialog 事件由 Page 分发。

🌐 Dialog instances are dispatched by the Page via the dialog event.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Dialog 类的子类。

🌐 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 class.

ElementHandle

ElementHandle 表示页内 DOM 元素。

🌐 ElementHandle represents an in-page DOM element.

附注

可以使用 Page.$() 方法创建 ElementHandles。

🌐 ElementHandles can be created with the Page.$() method.

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 会防止 DOM 元素被垃圾回收,除非该句柄被释放。当其关联的框架被导航到其他页面或父上下文被销毁时,ElementHandle 会自动被释放。

🌐 ElementHandle prevents the DOM element from being garbage-collected unless the handle is disposed. ElementHandles are auto-disposed when their associated frame is navigated away or the parent context gets destroyed.

ElementHandle 实例可以作为 Page.$eval()Page.evaluate() 方法的参数使用。

🌐 ElementHandle instances can be used as arguments in Page.$eval() and Page.evaluate() methods.

如果你使用 TypeScript,ElementHandle 需要一个泛型参数,用来表示句柄所持有的元素类型。例如,如果你有一个指向 <select> 元素的句柄,你可以将其类型标注为 ElementHandle<HTMLSelectElement>,这样你就可以获得更好的类型检查。

🌐 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 <select> element, you can type it as ElementHandle<HTMLSelectElement> and you get some nicer type checks.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 ElementHandle 类的子类。

🌐 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 class.

EventEmitter

许多 Puppeteer 类扩展的 EventEmitter 类。

🌐 The EventEmitter class that many Puppeteer classes extend.

附注

这使你可以监听 Puppeteer 类触发的事件并相应地采取行动。因此,你大多数时候会使用 onoff 来绑定和解绑事件监听器。

🌐 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.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 EventEmitter 类的子类。

🌐 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 class.

ExtensionTransport

(实验) 实验性 ExtensionTransport 允许在 Puppeteer 以扩展程序运行时通过 chrome.debugger API 建立连接。由于 Chrome DevTools 协议对扩展程序有限制,该传输实现了缺失的命令和事件。

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 ExtensionTransport 类的子类。

🌐 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 class.

FileChooser

文件选择器可让你对请求文件的页面做出反应。

🌐 File choosers let you react to the page requesting for a file.

附注

FileChooser 实例通过 Page.waitForFileChooser() 方法返回。

在浏览器中,一次只能打开一个文件选择器。所有文件选择器必须被接受或取消。如果不这样做,将阻止后续的文件选择器出现。

🌐 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.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 FileChooser 类的子类。

🌐 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 class.

Frame

代表一个 DOM 框架。

🌐 Represents a DOM frame.

要理解框架,你可以把框架看作是 <iframe> 元素。就像 iframes 一样,框架可以嵌套,而且当 JavaScript 在一个框架中执行时,JavaScript 不会影响其执行环境框架内部的其他框架。

🌐 To understand frames, you can think of frames as <iframe> elements. Just like iframes, frames can be nested, and when JavaScript is executed in a frame, the JavaScript does not affect frames inside the ambient frame the JavaScript executes in.

附注

框架的生命周期由三个事件控制,这些事件都会在父页面上分发:

🌐 Frame lifecycles are controlled by three events that are all dispatched on the parent page:

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Frame 类的子类。

🌐 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 class.

HTTPRequest

表示页面发送的 HTTP 请求。

🌐 Represents an HTTP request sent by a page.

附注

每当页面发送请求(例如请求网络资源)时,Puppeteer 的 page 会触发以下事件:

🌐 Whenever the page sends a request, such as for a network resource, the following events are emitted by Puppeteer's page:

  • request:当页面发送请求时触发。
  • requestfinished - 当下载响应正文并且请求完成时触发。

如果请求在某个阶段失败,那么会发送 requestfailed 事件,而不是 requestfinished 事件。

🌐 If request fails at some point, then instead of requestfinished event the requestfailed event is emitted.

所有这些事件都提供了一个 HTTPRequest 表示发生的请求的实例:

🌐 All of these events provide an instance of HTTPRequest representing the request that occurred:

page.on('request', request => ...)

注意:HTTP 错误响应,例如 404 或 503,从 HTTP 的角度来看仍然是成功的响应,因此请求将以 requestfinished 事件完成。

🌐 NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with requestfinished event.

如果请求收到“重定向”响应,请求将通过 requestfinished 事件成功完成,并且会向重定向的 URL 发出一个新的请求。

🌐 If request gets a 'redirect' response, the request is successfully finished with the requestfinished event, and a new request is issued to a redirected url.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 HTTPRequest 类的子类。

🌐 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 class.

HTTPResponse

HTTPResponse 类表示由 Page 类接收的响应。

🌐 The HTTPResponse class represents responses which are received by the Page class.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 HTTPResponse 类的子类。

🌐 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 class.

JSCoverage

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 JSCoverage 类的子类。

🌐 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 class.

JSHandle

表示对 JavaScript 对象的引用。可以使用 Page.evaluateHandle() 创建实例。

🌐 Represents a reference to a JavaScript object. Instances can be created using Page.evaluateHandle().

句柄可以防止被引用的 JavaScript 对象被垃圾回收,除非该句柄被有意地释放。当其关联的框架被导航或父上下文被销毁时,JSHandles 会自动释放。

🌐 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.

句柄可以用作任何评估函数的参数,例如 Page.$eval()Page.evaluate()Page.evaluateHandle()。它们会被解析为其引用的对象。

🌐 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.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 JSHandle 类的子类。

🌐 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 class.

Keyboard

Keyboard 提供了一个用于管理虚拟键盘的 API。高级 API 是 Keyboard.type(),它接收原始字符并在你的页面上生成适当的 keydown、keypress/input 和 keyup 事件。

🌐 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.

附注

为了更精细的控制,你可以使用 Keyboard.down()Keyboard.up()Keyboard.sendCharacter() 来手动触发事件,就像它们是由真实键盘生成的一样。

🌐 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.

在 macOS 上,像 ⌘ A -> 全选 这样的键盘快捷键不能使用。请参见 #1313

🌐 On macOS, keyboard shortcuts like ⌘ A -> Select All do not work. See #1313.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Keyboard 类的子类。

🌐 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 class.

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.

详情请参见 https://pptr.nodejs.cn/guides/page-interactions#locators

🌐 See https://pptr.nodejs.cn/guides/page-interactions#locators for details.

Mouse

Mouse 类在相对于视口左上角的主框架 CSS 像素中运行。

🌐 The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.

附注

每个 page 对象都有自己的鼠标,可以通过 Page.mouse 访问。

🌐 Every page object has its own Mouse, accessible with Page.mouse.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Mouse 类的子类。

🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Mouse class.

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.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 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 Page class.

ProtocolError

每当协议出现错误时就会触发 ProtocolError。

🌐 ProtocolError is emitted whenever there is an error from the protocol.

Puppeteer

主要的 Puppeteer 职业。

🌐 The main Puppeteer class.

重要提示:如果你在 Node 环境中使用 Puppeteer,当你导入或 require puppeteer 时,将会得到一个 PuppeteerNode 的实例。该类继承自 Puppeteer,因此不仅拥有下面文档中列出的所有方法,还拥有在 PuppeteerNode 上定义的所有方法。

🌐 IMPORTANT: if you are using Puppeteer in a Node environment, you will get an instance of PuppeteerNode when you import or require puppeteer. That class extends Puppeteer, so has all the methods documented below as well as all that are defined on PuppeteerNode.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Puppeteer 类的子类。

🌐 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 class.

PuppeteerError

所有 Puppeteer 特定错误的基类

🌐 The base class for all Puppeteer-specific errors

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 PuppeteerError 类的子类。

🌐 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 class.

PuppeteerNode

扩展主要的 Puppeteer 类,增加用于获取和下载浏览器的 Node 特定行为。

🌐 Extends the main Puppeteer class with Node specific behaviour for fetching and downloading browsers.

如果你在 Node 环境中使用 Puppeteer,当你运行 require('puppeteer')(或等效的 ES import)时,你将得到这个类。

🌐 If you're using Puppeteer in a Node environment, this is the class you'll get when you run require('puppeteer') (or the equivalent ES import).

附注

最常用的方法是 launch,它用于启动并连接到新的浏览器实例。

🌐 The most common method to use is launch, which is used to launch and connect to a new browser instance.

请参阅 主 Puppeteer 类 以了解适用于所有环境的方法,例如 Puppeteer.connect()

🌐 See the main Puppeteer class for methods common to all environments, such as Puppeteer.connect().

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 PuppeteerNode 类的子类。

🌐 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 class.

ScreenRecorder

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 ScreenRecorder 类的子类。

🌐 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 class.

SecurityDetails

SecurityDetails 类表示通过安全连接接收到的响应的安全详细信息。

🌐 The SecurityDetails class represents the security details of a response that was received over a secure connection.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 SecurityDetails 类的子类。

🌐 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 class.

Target

Target 表示一个 CDP 目标。在 CDP 中,目标是可以调试的对象,例如框架、页面或工作线程。

🌐 Target represents a CDP target. In CDP a target is something that can be debugged such a frame, a page or a worker.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Target 类的子类。

🌐 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 class.

TimeoutError

每当某些操作由于超时而终止时,就会触发 TimeoutError。

🌐 TimeoutError is emitted whenever certain operations are terminated due to timeout.

附注

示例操作有 page.waitForSelectorpuppeteer.launch

🌐 Example operations are page.waitForSelector or puppeteer.launch.

TouchError

当尝试移动或结束不存在的触摸时,将抛出 TouchError。

🌐 TouchError is thrown when an attempt is made to move or end a touch that does not exist.

Touchscreen

Touchscreen 类公开触摸屏事件。

🌐 The Touchscreen class exposes touchscreen events.

附注

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Touchscreen 类的子类。

🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Touchscreen class.

Tracing

Tracing 类公开跟踪审计接口。

🌐 The Tracing class exposes the tracing audit interface.

附注

你可以使用 tracing.starttracing.stop 创建一个 trace 文件,该文件可以在 Chrome 开发者工具或 timeline viewer 中打开。

🌐 You can use tracing.start and tracing.stop to create a trace file which can be opened in Chrome DevTools or timeline viewer.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Tracing 类的子类。

🌐 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 class.

UnsupportedOperation

如果当前使用的协议不支持某个方法,Puppeteer 将抛出此错误

🌐 Puppeteer will throw this error if a method is not supported by the currently used protocol

WebWorker

这个类表示一个 WebWorker

🌐 This class represents a WebWorker.

附注

事件 workercreatedworkerdestroyed 会在页面对象上触发,以表示工作线程的生命周期。

🌐 The events workercreated and workerdestroyed are emitted on the page object to signal the worker lifecycle.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 WebWorker 类的子类。

🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the WebWorker class.

枚举

🌐 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
AddScreenParams
AutofillData
BluetoothEmulation

(实验性) 显示蓝牙模拟功能。

附注

Web Bluetooth 规范 要求模拟适配器应按顶层可导航对象进行隔离。然而,目前 Chromium 的蓝牙模拟实现是绑定到浏览器上下文,而不是页面。这意味着从同一浏览器上下文的不同页面暴露的蓝牙模拟会相互干扰它们的状态。

BluetoothManufacturerData

表示模拟蓝牙外设的制造商数据。

🌐 Represents the simulated bluetooth peripheral's manufacturer data.

BoundingBox
BoxModel
BrowserContextEvents
BrowserContextOptions
BrowserEvents
CDPSessionEvents
ChromeHeadlessShellSettings
ChromeSettings
ClickOptions
CommandOptions
CommonEventEmitter
Configuration

定义在安装和运行时配置 Puppeteer 行为的选项。

🌐 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
Cookie

代表一个 cookie 对象。

🌐 Represents a cookie object.

CookieData

用于在浏览器级 cookies API 中设置 cookies 的 Cookie 参数对象。

🌐 Cookie parameter object used to set cookies in the browser-level cookies API.

CookieParam

用于在页面级 cookies API 中设置 cookies 的 Cookie 参数对象。

🌐 Cookie parameter object used to set cookies in the page-level cookies API.

CookiePartitionKey

表示 Chrome 中的 cookie 分区键。

🌐 Represents a cookie partition key in Chrome.

CoverageEntry

CoverageEntry 类代表覆盖率报告的一项。

🌐 The CoverageEntry class represents one entry of the coverage report.

Credentials
CSSCoverageOptions

CSS 覆盖范围的一组可配置选项。

🌐 Set of configurable options for CSS coverage.

CustomQueryHandler
DebugInfo

(实验性)

DeleteCookiesRequest
Device
DeviceRequestPromptDevice

设备处于请求提示状态。

🌐 Device in a request prompt.

DownloadBehavior
ElementScreenshotOptions
FirefoxSettings
FrameAddScriptTagOptions
FrameAddStyleTagOptions
FrameEvents
FrameWaitForFunctionOptions
GeolocationOptions
GoToOptions
HeapSnapshotOptions

[Page.captureHeapSnapshot()] 的选项。

🌐 Options for Page.captureHeapSnapshot().

InterceptResolutionState
InternalNetworkConditions
JSCoverageEntry

JavaScript 的 CoverageEntry 类

🌐 The CoverageEntry class for JavaScript

JSCoverageOptions

JS 覆盖率的一组可配置选项。

🌐 Set of configurable options for JS coverage.

KeyboardTypeOptions
KeyDownOptions
LaunchOptions

启动任何浏览器时可以传递的通用启动选项。

🌐 Generic launch options that can be passed when launching any browser.

LocatorEvents
LocatorFillOptions
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.

有关事件以及它们何时触发的更多详细信息,请参见 PageEvent

🌐 See PageEvent for more detail on the events and when they are emitted.

PDFMargin
PDFOptions

通过 Page.pdf() 配置 PDF 生成的有效选项。

🌐 Valid options to configure PDF generation via Page.pdf().

PermissionDescriptor_2
Point
PreconnectedPeripheral

要模拟的蓝牙外设。

🌐 A bluetooth peripheral to be simulated.

QueryOptions
ReloadOptions
RemoteAddress
ResponseForRequest

满足请求所需的响应数据。

🌐 Required response data to fulfill a request with.

ScreencastOptions

(实验性)

ScreenInfo
ScreenOrientation_2
ScreenshotClip
ScreenshotOptions
SerializedAXNode

表示一个节点及其与可访问性相关的属性。

🌐 Represents a Node and the properties of it that are relevant to Accessibility.

SnapshotOptions
SupportedWebDriverCapabilities

Puppeteer 本身未设置的 WebDriver BiDi 功能。

🌐 WebDriver BiDi capabilities that are not set by Puppeteer itself.

TouchHandle

TouchHandle 接口公开了用于操作已启动触摸的方法

🌐 The TouchHandle interface exposes methods to manipulate touches that have been started

TracingOptions
Viewport
WaitForNetworkIdleOptions
WaitForOptions
WaitForSelectorOptions
WaitForTargetOptions
WaitTimeoutOptions
WindowBounds
WorkAreaInsets

命名空间

🌐 Namespaces

命名空间

🌐 Namespace

描述

🌐 Description

CDPSessionEvent

CDPSession 类触发的事件。

🌐 Events that the CDPSession class emits.

变量

🌐 Variables

多变的

🌐 Variable

描述

🌐 Description

DEFAULT_INTERCEPT_RESOLUTION_PRIORITY

默认协同请求拦截解析优先级

🌐 The default cooperative request interception resolution priority

executablePath
KnownDevices

用于 Page.emulate() 的设备列表。

🌐 A list of devices to be used with Page.emulate().

MouseButton

有效鼠标按钮的枚举。

🌐 Enum of valid mouse buttons.

PredefinedNetworkConditions

用于与 Page.emulateNetworkConditions() 一起使用的预定义网络条件列表。

🌐 A list of pre-defined network conditions to be used with Page.emulateNetworkConditions().

puppeteer

类型别名

🌐 Type Aliases

类型别名

🌐 Type Alias

描述

🌐 Description

ActionResult
AdapterState

模拟蓝牙适配器状态。

🌐 Emulated bluetooth adapter state.

Awaitable
AwaitableIterable
AwaitablePredicate
AwaitedLocator
CDPEvents
ChromeReleaseChannel
ConsoleMessageType

控制台消息支持的类型。

🌐 The supported types for console messages.

CookiePriority

表示 cookie 的“优先级”状态:https://tools.ietf.org/html/draft-west-cookie-priority-00

🌐 Represents the cookie's 'Priority' status: https://tools.ietf.org/html/draft-west-cookie-priority-00

CookieSameSite

表示 cookie 的 'SameSite' 状态:https://tools.ietf.org/html/draft-west-first-party-cookies

🌐 Represents the cookie's 'SameSite' status: https://tools.ietf.org/html/draft-west-first-party-cookies

CookieSourceScheme

表示最初设置 cookie 的源方案。值为“Unset”允许协议客户端模拟方案的传统 cookie 范围。这是暂时的功能,将来会被移除。

🌐 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.

CreatePageOptions
DownloadPolicy
ElementFor
ErrorCode
EvaluateFunc
EvaluateFuncWith
EventsWithWildcard
EventType
ExperimentsConfiguration

定义 Puppeteer 的实验选项。

🌐 Defines experiment options for Puppeteer.

有关详细信息,请参阅各个属性。

🌐 See individual properties for more information.

FlattenHandle
HandleFor
HandleOr
Handler
ImageFormat
InnerParams
KeyInput

所有可以传递给接受用户输入的函数的有效键,例如 keyboard.press

🌐 All the valid keys that can be passed to functions that take user input, such as keyboard.press

KeyPressOptions
LocatorClickOptions
LowerCasePaperFormat
Mapper
MouseButton
NodeFor
PaperFormat

打印 PDF 时的所有有效纸张格式类型。

🌐 All the valid paper format types when printing a PDF.

附注

每种格式的大小如下:

🌐 The sizes of each format are as follows:

  • Letter:8.5 英寸 x 11 英寸 / 21.59 厘米 x 27.94 厘米
  • Legal:8.5 英寸 x 14 英寸 / 21.59 厘米 x 35.56 厘米
  • Tabloid:11 英寸 x 17 英寸 / 27.94 厘米 x 43.18 厘米
  • Ledger:17 英寸 x 11 英寸 / 43.18 厘米 x 27.94 厘米
  • A0:33.1102 英寸 x 46.811 英寸 / 84.1 厘米 x 118.9 厘米
  • A1:23.3858 英寸 x 33.1102 英寸 / 59.4 厘米 x 84.1 厘米
  • A2:16.5354 英寸 x 23.3858 英寸 / 42 厘米 x 59.4 厘米
  • A3:11.6929 英寸 x 16.5354 英寸 / 29.7 厘米 x 42 厘米
  • A4:8.2677 英寸 x 11.6929 英寸 / 21 厘米 x 29.7 厘米
  • A5:5.8268 英寸 x 8.2677 英寸 / 14.8 厘米 x 21 厘米
  • A6:4.1339 英寸 x 5.8268 英寸 / 10.5 厘米 x 14.8 厘米
Permission

已弃用:

赞成

🌐 in favor of .

PermissionState_2
Predicate
ProtocolLifeCycleEvent
ProtocolType
PuppeteerLifeCycleEvent
Quad
ResourceType

渲染引擎感知到的 HTTPRequest 的资源类型。

🌐 Resource types for HTTPRequests as perceived by the rendering engine.

SupportedBrowser

Puppeteer 支持的浏览器。

🌐 Browsers supported by Puppeteer.

SupportedWebDriverCapability
TargetFilterCallback
VideoFormat
VisibilityOption

是否等待元素变为可见隐藏null用于禁用可见性检查。

🌐 Whether to wait for the element to be visible or hidden. null to disable visibility checks.

WindowId
WindowState