docs: add DeviceRequestPrompt documentation (#9918)
This commit is contained in:
parent
16bf0dc798
commit
bb37df5f64
@ -7,7 +7,7 @@ sidebar_label: API
|
|||||||
## Classes
|
## Classes
|
||||||
|
|
||||||
| Class | Description |
|
| Class | Description |
|
||||||
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [Accessibility](./puppeteer.accessibility.md) | The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or [switches](https://en.wikipedia.org/wiki/Switch_access). |
|
| [Accessibility](./puppeteer.accessibility.md) | The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or [switches](https://en.wikipedia.org/wiki/Switch_access). |
|
||||||
| [Browser](./puppeteer.browser.md) | A Browser is created when Puppeteer connects to a Chromium instance, either through [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md) or [Puppeteer.connect()](./puppeteer.puppeteer.connect.md). |
|
| [Browser](./puppeteer.browser.md) | A Browser is created when Puppeteer connects to a Chromium instance, either through [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md) or [Puppeteer.connect()](./puppeteer.puppeteer.connect.md). |
|
||||||
| [BrowserContext](./puppeteer.browsercontext.md) | BrowserContexts provide a way to operate multiple independent browser sessions. When a browser is launched, it has a single BrowserContext used by default. The method [Browser.newPage](./puppeteer.browser.newpage.md) creates a page in the default browser context. |
|
| [BrowserContext](./puppeteer.browsercontext.md) | BrowserContexts provide a way to operate multiple independent browser sessions. When a browser is launched, it has a single BrowserContext used by default. The method [Browser.newPage](./puppeteer.browser.newpage.md) creates a page in the default browser context. |
|
||||||
@ -18,6 +18,8 @@ sidebar_label: API
|
|||||||
| [Coverage](./puppeteer.coverage.md) | The Coverage class provides methods to gathers information about parts of JavaScript and CSS that were used by the page. |
|
| [Coverage](./puppeteer.coverage.md) | The Coverage class provides methods to gathers information about parts of JavaScript and CSS that were used by the page. |
|
||||||
| [CSSCoverage](./puppeteer.csscoverage.md) | |
|
| [CSSCoverage](./puppeteer.csscoverage.md) | |
|
||||||
| [CustomError](./puppeteer.customerror.md) | |
|
| [CustomError](./puppeteer.customerror.md) | |
|
||||||
|
| [DeviceRequestPrompt](./puppeteer.devicerequestprompt.md) | Device request prompts let you respond to the page requesting for a device through an API like WebBluetooth. |
|
||||||
|
| [DeviceRequestPromptDevice](./puppeteer.devicerequestpromptdevice.md) | Device in a request prompt. |
|
||||||
| [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the <code>dialog</code> event. |
|
| [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the <code>dialog</code> event. |
|
||||||
| [ElementHandle](./puppeteer.elementhandle.md) | ElementHandle represents an in-page DOM element. |
|
| [ElementHandle](./puppeteer.elementhandle.md) | ElementHandle represents an in-page DOM element. |
|
||||||
| [EventEmitter](./puppeteer.eventemitter.md) | The EventEmitter class that many Puppeteer classes extend. |
|
| [EventEmitter](./puppeteer.eventemitter.md) | The EventEmitter class that many Puppeteer classes extend. |
|
||||||
|
19
docs/api/puppeteer.devicerequestprompt.cancel.md
Normal file
19
docs/api/puppeteer.devicerequestprompt.cancel.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPrompt.cancel
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPrompt.cancel() method
|
||||||
|
|
||||||
|
Cancel the prompt.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class DeviceRequestPrompt {
|
||||||
|
cancel(): Promise<void>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<void>
|
15
docs/api/puppeteer.devicerequestprompt.devices.md
Normal file
15
docs/api/puppeteer.devicerequestprompt.devices.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPrompt.devices
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPrompt.devices property
|
||||||
|
|
||||||
|
Current list of selectable devices.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class DeviceRequestPrompt {
|
||||||
|
devices: DeviceRequestPromptDevice[];
|
||||||
|
}
|
||||||
|
```
|
45
docs/api/puppeteer.devicerequestprompt.md
Normal file
45
docs/api/puppeteer.devicerequestprompt.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPrompt
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPrompt class
|
||||||
|
|
||||||
|
Device request prompts let you respond to the page requesting for a device through an API like WebBluetooth.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export declare class DeviceRequestPrompt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
`DeviceRequestPrompt` instances are returned via the [Page.waitForDevicePrompt()](./puppeteer.page.waitfordeviceprompt.md) method.
|
||||||
|
|
||||||
|
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `DeviceRequestPrompt` class.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const [deviceRequest] = Promise.all([
|
||||||
|
page.waitForDevicePrompt(),
|
||||||
|
page.click('#connect-bluetooth'),
|
||||||
|
]);
|
||||||
|
await devicePrompt.select(
|
||||||
|
await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description |
|
||||||
|
| ----------------------------------------------------- | --------- | ------------------------------------------------------------------------- | ----------------------------------- |
|
||||||
|
| [devices](./puppeteer.devicerequestprompt.devices.md) | | [DeviceRequestPromptDevice](./puppeteer.devicerequestpromptdevice.md)\[\] | Current list of selectable devices. |
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
| Method | Modifiers | Description |
|
||||||
|
| ---------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------ |
|
||||||
|
| [cancel()](./puppeteer.devicerequestprompt.cancel.md) | | Cancel the prompt. |
|
||||||
|
| [select(device)](./puppeteer.devicerequestprompt.select.md) | | Select a device in the prompt's list. |
|
||||||
|
| [waitForDevice(filter, options)](./puppeteer.devicerequestprompt.waitfordevice.md) | | Resolve to the first device in the prompt matching a filter. |
|
25
docs/api/puppeteer.devicerequestprompt.select.md
Normal file
25
docs/api/puppeteer.devicerequestprompt.select.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPrompt.select
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPrompt.select() method
|
||||||
|
|
||||||
|
Select a device in the prompt's list.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class DeviceRequestPrompt {
|
||||||
|
select(device: DeviceRequestPromptDevice): Promise<void>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
| Parameter | Type | Description |
|
||||||
|
| --------- | --------------------------------------------------------------------- | ----------- |
|
||||||
|
| device | [DeviceRequestPromptDevice](./puppeteer.devicerequestpromptdevice.md) | |
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<void>
|
29
docs/api/puppeteer.devicerequestprompt.waitfordevice.md
Normal file
29
docs/api/puppeteer.devicerequestprompt.waitfordevice.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPrompt.waitForDevice
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPrompt.waitForDevice() method
|
||||||
|
|
||||||
|
Resolve to the first device in the prompt matching a filter.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class DeviceRequestPrompt {
|
||||||
|
waitForDevice(
|
||||||
|
filter: (device: DeviceRequestPromptDevice) => boolean,
|
||||||
|
options?: WaitTimeoutOptions
|
||||||
|
): Promise<DeviceRequestPromptDevice>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
| Parameter | Type | Description |
|
||||||
|
| --------- | --------------------------------------------------------------------------------------------- | ------------ |
|
||||||
|
| filter | (device: [DeviceRequestPromptDevice](./puppeteer.devicerequestpromptdevice.md)) => boolean | |
|
||||||
|
| options | [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) | _(Optional)_ |
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<[DeviceRequestPromptDevice](./puppeteer.devicerequestpromptdevice.md)>
|
15
docs/api/puppeteer.devicerequestpromptdevice.id.md
Normal file
15
docs/api/puppeteer.devicerequestpromptdevice.id.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPromptDevice.id
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPromptDevice.id property
|
||||||
|
|
||||||
|
Device id during a prompt.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class DeviceRequestPromptDevice {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
```
|
24
docs/api/puppeteer.devicerequestpromptdevice.md
Normal file
24
docs/api/puppeteer.devicerequestpromptdevice.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPromptDevice
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPromptDevice class
|
||||||
|
|
||||||
|
Device in a request prompt.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export declare class DeviceRequestPromptDevice
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `DeviceRequestPromptDevice` class.
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description |
|
||||||
|
| ----------------------------------------------------- | --------- | ------ | -------------------------------------- |
|
||||||
|
| [id](./puppeteer.devicerequestpromptdevice.id.md) | | string | Device id during a prompt. |
|
||||||
|
| [name](./puppeteer.devicerequestpromptdevice.name.md) | | string | Device name as it appears in a prompt. |
|
15
docs/api/puppeteer.devicerequestpromptdevice.name.md
Normal file
15
docs/api/puppeteer.devicerequestpromptdevice.name.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: DeviceRequestPromptDevice.name
|
||||||
|
---
|
||||||
|
|
||||||
|
# DeviceRequestPromptDevice.name property
|
||||||
|
|
||||||
|
Device name as it appears in a prompt.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class DeviceRequestPromptDevice {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
```
|
@ -30,7 +30,7 @@ class Frame {
|
|||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
Promise<DeviceRequestPrompt>
|
Promise<[DeviceRequestPrompt](./puppeteer.devicerequestprompt.md)>
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class Page {
|
|||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
Promise<DeviceRequestPrompt>
|
Promise<[DeviceRequestPrompt](./puppeteer.devicerequestprompt.md)>
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import {DeferredPromise} from '../util/DeferredPromise.js';
|
|||||||
|
|
||||||
import {CDPSession} from './Connection.js';
|
import {CDPSession} from './Connection.js';
|
||||||
import {EventEmitter} from './EventEmitter.js';
|
import {EventEmitter} from './EventEmitter.js';
|
||||||
import {Frame} from './Frame.js';
|
import {FrameManager} from './FrameManager.js';
|
||||||
import {HTTPRequest} from './HTTPRequest.js';
|
import {HTTPRequest} from './HTTPRequest.js';
|
||||||
import {HTTPResponse} from './HTTPResponse.js';
|
import {HTTPResponse} from './HTTPResponse.js';
|
||||||
import {FetchRequestId, NetworkEventManager} from './NetworkEventManager.js';
|
import {FetchRequestId, NetworkEventManager} from './NetworkEventManager.js';
|
||||||
@ -68,20 +68,13 @@ export const NetworkManagerEmittedEvents = {
|
|||||||
RequestFinished: Symbol('NetworkManager.RequestFinished'),
|
RequestFinished: Symbol('NetworkManager.RequestFinished'),
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
interface FrameManager {
|
|
||||||
frame(frameId: string): Frame | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class NetworkManager extends EventEmitter {
|
export class NetworkManager extends EventEmitter {
|
||||||
#client: CDPSession;
|
#client: CDPSession;
|
||||||
#ignoreHTTPSErrors: boolean;
|
#ignoreHTTPSErrors: boolean;
|
||||||
#frameManager: FrameManager;
|
#frameManager: Pick<FrameManager, 'frame'>;
|
||||||
#networkEventManager = new NetworkEventManager();
|
#networkEventManager = new NetworkEventManager();
|
||||||
#extraHTTPHeaders: Record<string, string> = {};
|
#extraHTTPHeaders: Record<string, string> = {};
|
||||||
#credentials?: Credentials;
|
#credentials?: Credentials;
|
||||||
@ -100,7 +93,7 @@ export class NetworkManager extends EventEmitter {
|
|||||||
constructor(
|
constructor(
|
||||||
client: CDPSession,
|
client: CDPSession,
|
||||||
ignoreHTTPSErrors: boolean,
|
ignoreHTTPSErrors: boolean,
|
||||||
frameManager: FrameManager
|
frameManager: Pick<FrameManager, 'frame'>
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.#client = client;
|
this.#client = client;
|
||||||
|
@ -21,6 +21,7 @@ import {Protocol} from 'devtools-protocol';
|
|||||||
import type {Browser} from '../api/Browser.js';
|
import type {Browser} from '../api/Browser.js';
|
||||||
import type {BrowserContext} from '../api/BrowserContext.js';
|
import type {BrowserContext} from '../api/BrowserContext.js';
|
||||||
import {ElementHandle} from '../api/ElementHandle.js';
|
import {ElementHandle} from '../api/ElementHandle.js';
|
||||||
|
import {HTTPRequest} from '../api/HTTPRequest.js';
|
||||||
import {HTTPResponse} from '../api/HTTPResponse.js';
|
import {HTTPResponse} from '../api/HTTPResponse.js';
|
||||||
import {JSHandle} from '../api/JSHandle.js';
|
import {JSHandle} from '../api/JSHandle.js';
|
||||||
import {
|
import {
|
||||||
@ -61,7 +62,6 @@ import {
|
|||||||
FrameWaitForFunctionOptions,
|
FrameWaitForFunctionOptions,
|
||||||
} from './Frame.js';
|
} from './Frame.js';
|
||||||
import {FrameManager, FrameManagerEmittedEvents} from './FrameManager.js';
|
import {FrameManager, FrameManagerEmittedEvents} from './FrameManager.js';
|
||||||
import {HTTPRequest} from './HTTPRequest.js';
|
|
||||||
import {Keyboard, Mouse, MouseButton, Touchscreen} from './Input.js';
|
import {Keyboard, Mouse, MouseButton, Touchscreen} from './Input.js';
|
||||||
import {WaitForSelectorOptions} from './IsolatedWorld.js';
|
import {WaitForSelectorOptions} from './IsolatedWorld.js';
|
||||||
import {MAIN_WORLD} from './IsolatedWorlds.js';
|
import {MAIN_WORLD} from './IsolatedWorlds.js';
|
||||||
|
@ -28,6 +28,7 @@ export * from './Coverage.js';
|
|||||||
export * from './CustomQueryHandler.js';
|
export * from './CustomQueryHandler.js';
|
||||||
export * from './Debug.js';
|
export * from './Debug.js';
|
||||||
export * from './Device.js';
|
export * from './Device.js';
|
||||||
|
export * from './DeviceRequestPrompt.js';
|
||||||
export * from './Dialog.js';
|
export * from './Dialog.js';
|
||||||
export * from './ElementHandle.js';
|
export * from './ElementHandle.js';
|
||||||
export * from './EmulationManager.js';
|
export * from './EmulationManager.js';
|
||||||
|
Loading…
Reference in New Issue
Block a user