Skip to main content
Version: 23.2.0

Page.$$() 方法

¥Page.$$() method

在页面上查找与选择器匹配的元素。如果没有元素与选择器匹配,则返回值解析为 []

¥Finds elements on the page that match the selector. If no elements match the selector, the return value resolves to [].

签名

¥Signature

class Page {
$$<Selector extends string>(
selector: Selector,
options?: QueryOptions
): Promise<Array<ElementHandle<NodeFor<Selector>>>>;
}

参数

¥Parameters

范围

类型

描述

selector

选择器

要查询页面的 selectorCSS 选择器 可以按原样传递,Puppeteer 特定的选择器语法 允许通过 texta11y 角色和名称xpath跨影子根组合这些查询 进行查询。或者,你可以使用 prefix 指定选择器类型。

options

QueryOptions

(可选的)

Returns:

Promise<Array<ElementHandle<NodeFor<Selector>>>>

备注

¥Remarks

Page.mainFrame().$$(selector) 的快捷方式。

¥Shortcut for Page.mainFrame().$$(selector).