Skip to main content
Version: 24.38.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.

caution

在发出设备请求之前必须调用此方法。它不会返回当前处于活动状态的设备提示。

🌐 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

范围

🌐 Parameter

类型

🌐 Type

描述

🌐 Description

options

WaitTimeoutOptions

(可选)

🌐 (Optional)

返回:

Promise<DeviceRequestPrompt>

示例

🌐 Example

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