From bc134551fb77c83e9420aad943320caefc735a52 Mon Sep 17 00:00:00 2001 From: Jeremy Hutchinson Date: Thu, 26 Jan 2023 05:49:10 -0500 Subject: [PATCH] docs(dotnet): add support for CDPSession (#20053) Implemented in https://github.com/microsoft/playwright-dotnet/pull/2448 Signed-off-by: Jeremy Hutchinson Co-authored-by: Jeremy Hutchinson Co-authored-by: Max Schmitt --- docs/src/api/class-browser.md | 2 +- docs/src/api/class-browsercontext.md | 2 +- docs/src/api/class-cdpsession.md | 41 ++++++++++++++++++++++++++- docs/src/api/class-cdpsessionevent.md | 17 +++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 docs/src/api/class-cdpsessionevent.md diff --git a/docs/src/api/class-browser.md b/docs/src/api/class-browser.md index bb516be613..bc6da6f2b1 100644 --- a/docs/src/api/class-browser.md +++ b/docs/src/api/class-browser.md @@ -155,7 +155,7 @@ Indicates that the browser is connected. ## async method: Browser.newBrowserCDPSession * since: v1.11 -* langs: js, python +* langs: js, python, csharp - returns: <[CDPSession]> :::note diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index fe3edc74b8..16f12aca48 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -857,7 +857,7 @@ The [origin] to grant permissions to, e.g. "https://example.com". ## async method: BrowserContext.newCDPSession * since: v1.11 -* langs: js, python +* langs: js, python, csharp - returns: <[CDPSession]> :::note diff --git a/docs/src/api/class-cdpsession.md b/docs/src/api/class-cdpsession.md index 70783247ff..e36c8ae607 100644 --- a/docs/src/api/class-cdpsession.md +++ b/docs/src/api/class-cdpsession.md @@ -1,6 +1,6 @@ # class: CDPSession * since: v1.8 -* langs: js, python +* langs: js, python, csharp * extends: [EventEmitter] The `CDPSession` instances are used to talk raw Chrome Devtools Protocol: @@ -45,6 +45,15 @@ client.send("Animation.setPlaybackRate", { 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 * since: v1.8 @@ -54,16 +63,46 @@ send messages. ## async method: CDPSession.send * since: v1.8 +* langs: js, python, csharp - returns: <[Object]> +## async method: CDPSession.send +* since: v1.30 +* langs: csharp +- returns: <[JsonElement?]> + ### param: CDPSession.send.method * since: v1.8 +* langs: js, python, csharp - `method` <[string]> Protocol method name. ### param: CDPSession.send.params * since: v1.8 +* langs: js, python - `params` ?<[Object]> Optional method parameters. + +### param: CDPSession.send.params +* since: v1.30 +* langs: csharp + - alias-csharp: args +- `params` ?<[Map]> + +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. \ No newline at end of file diff --git a/docs/src/api/class-cdpsessionevent.md b/docs/src/api/class-cdpsessionevent.md new file mode 100644 index 0000000000..e5f317d0ec --- /dev/null +++ b/docs/src/api/class-cdpsessionevent.md @@ -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]> \ No newline at end of file