Page.waitForDevicePrompt() 方法
此方法通常与触发设备请求的动作(例如 WebBluetooth 等 API)配合使用。
警告
必须在发出设备请求之前调用此方法。它不会返回当前处于活动状态的设备请求提示。
签名
class Page {
abstract waitForDevicePrompt(
options?: WaitTimeoutOptions,
): Promise<DeviceRequestPrompt>;
}
参数
|
参数 |
类型 |
说明 |
|---|---|---|
|
options |
(可选) |
返回值:
Promise<DeviceRequestPrompt>
示例
const [devicePrompt] = Promise.all([
page.waitForDevicePrompt(),
page.click('#connect-bluetooth'),
]);
await devicePrompt.select(
await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
);