Skip to main content
Version: 23.8.0

Page.waitForDevicePrompt() 方法

¥Page.waitForDevicePrompt() method

此方法通常与从 API(例如 WebBluetooth)触发设备请求的操作结合使用。

¥This method is typically coupled with an action that triggers a device request from an api such as WebBluetooth.

提醒

必须在发送设备请求之前调用此函数。它不会返回当前活动的设备提示。

¥This must be called before the device request is made. It will not return a currently active device prompt.

签名

¥Signature

class Page {
abstract waitForDevicePrompt(
options?: WaitTimeoutOptions,
): Promise<DeviceRequestPrompt>;
}

参数

¥Parameters

范围

类型

描述

options

WaitTimeoutOptions

(可选的)

Returns:

Promise<DeviceRequestPrompt>

示例

¥Example

const [devicePrompt] = Promise.all([
page.waitForDevicePrompt(),
page.click('#connect-bluetooth'),
]);
await devicePrompt.select(
await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
);