docs(dotnet): add support for CDPSession (#20053)

Implemented in https://github.com/microsoft/playwright-dotnet/pull/2448

Signed-off-by: Jeremy Hutchinson <jrhutch@live.com>
Co-authored-by: Jeremy Hutchinson <jehutchi@microsoft.com>
Co-authored-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Jeremy Hutchinson 2023-01-26 05:49:10 -05:00 committed by GitHub
parent 5761a62b1c
commit bc134551fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 3 deletions

View File

@ -155,7 +155,7 @@ Indicates that the browser is connected.
## async method: Browser.newBrowserCDPSession ## async method: Browser.newBrowserCDPSession
* since: v1.11 * since: v1.11
* langs: js, python * langs: js, python, csharp
- returns: <[CDPSession]> - returns: <[CDPSession]>
:::note :::note

View File

@ -857,7 +857,7 @@ The [origin] to grant permissions to, e.g. "https://example.com".
## async method: BrowserContext.newCDPSession ## async method: BrowserContext.newCDPSession
* since: v1.11 * since: v1.11
* langs: js, python * langs: js, python, csharp
- returns: <[CDPSession]> - returns: <[CDPSession]>
:::note :::note

View File

@ -1,6 +1,6 @@
# class: CDPSession # class: CDPSession
* since: v1.8 * since: v1.8
* langs: js, python * langs: js, python, csharp
* extends: [EventEmitter] * extends: [EventEmitter]
The `CDPSession` instances are used to talk raw Chrome Devtools Protocol: The `CDPSession` instances are used to talk raw Chrome Devtools Protocol:
@ -45,6 +45,15 @@ client.send("Animation.setPlaybackRate", {
playbackRate: response["playbackRate"] / 2 playbackRate: response["playbackRate"] / 2
}) })
``` ```
```csharp
var client = await Page.Context.NewCDPSessionAsync(Page);
await client.SendAsync("Runtime.enable");
client.Event("Animation.animationCreated").OnEvent += (_, _) => Console.WriteLine("Animation created!");
var response = await client.SendAsync("Animation.getPlaybackRate");
var playbackRate = response.Value.GetProperty("playbackRate").GetDouble();
Console.WriteLine("playback rate is " + playbackRate);
await client.SendAsync("Animation.setPlaybackRate", new() { { "playbackRate", playbackRate / 2 } });
```
## async method: CDPSession.detach ## async method: CDPSession.detach
* since: v1.8 * since: v1.8
@ -54,16 +63,46 @@ send messages.
## async method: CDPSession.send ## async method: CDPSession.send
* since: v1.8 * since: v1.8
* langs: js, python, csharp
- returns: <[Object]> - returns: <[Object]>
## async method: CDPSession.send
* since: v1.30
* langs: csharp
- returns: <[JsonElement?]>
### param: CDPSession.send.method ### param: CDPSession.send.method
* since: v1.8 * since: v1.8
* langs: js, python, csharp
- `method` <[string]> - `method` <[string]>
Protocol method name. Protocol method name.
### param: CDPSession.send.params ### param: CDPSession.send.params
* since: v1.8 * since: v1.8
* langs: js, python
- `params` ?<[Object]> - `params` ?<[Object]>
Optional method parameters. Optional method parameters.
### param: CDPSession.send.params
* since: v1.30
* langs: csharp
- alias-csharp: args
- `params` ?<[Map<string, Object>]>
Optional method parameters.
## method: CDPSession.event
* since: v.1.30
* langs: csharp
- returns: <[CDPSessionEvent]>
Returns an event emitter for the given CDP event name.
### param: CDPSession.event.eventName
* since: v1.30
* langs: csharp
- `eventName` <[string]>
CDP event name.

View File

@ -0,0 +1,17 @@
# class: CDPSessionEvent
* since: v1.30
* langs: csharp
[CDPSessionEvent] objects are returned by page via the [`method: CDPSession.event`] method.
Each object represents a named event and allows handling of the event when it is raised.
## event: CDPSessionEvent.onEvent
* since: v1.30
* langs: csharp
- argument: <[JsonElement?]>
## property: CDPSessionEvent.eventName
* since: 1.30
* langs: csharp
- returns: <[string]>