Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(java): add support for Chrome DevTools Protocol (#24150)

Raphi2d9cdb6ab4f7
diff --git a/docs/src/api/class-browser.md b/docs/src/api/class-browser.md
index b25da29e13..ee6d29b009 100644
--- a/docs/src/api/class-browser.md
+++ b/docs/src/api/class-browser.md
@@ -155,7 +155,6 @@ Indicates that the browser is connected.
## async method: Browser.newBrowserCDPSession
* since: v1.11
-* langs: js, python, csharp
- returns: <[CDPSession]>
:::note
diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md
index 543f31352d..63e93a146c 100644
--- a/docs/src/api/class-browsercontext.md
+++ b/docs/src/api/class-browsercontext.md
@@ -968,7 +968,6 @@ The [origin] to grant permissions to, e.g. "https://example.com".
## async method: BrowserContext.newCDPSession
* since: v1.11
-* langs: js, python, csharp
- returns: <[CDPSession]>
:::note
diff --git a/docs/src/api/class-cdpsession.md b/docs/src/api/class-cdpsession.md
index e36c8ae607..68117427a6 100644
--- a/docs/src/api/class-cdpsession.md
+++ b/docs/src/api/class-cdpsession.md
@@ -1,6 +1,5 @@
# class: CDPSession
* since: v1.8
-* langs: js, python, csharp
* extends: [EventEmitter]
The `CDPSession` instances are used to talk raw Chrome Devtools Protocol:
@@ -54,6 +53,20 @@ var playbackRate = response.Value.GetProperty("playbackRate").GetDouble();
Console.WriteLine("playback rate is " + playbackRate);
await client.SendAsync("Animation.setPlaybackRate", new() { { "playbackRate", playbackRate / 2 } });
```
+```java
+CDPSession client = page.context().newCDPSession(page);
+client.send("Runtime.enable");
+
+client.on("Animation.animationCreated", (event) -> System.out.println("Animation created!"));
+
+JsonObject response = client.send("Animation.getPlaybackRate");
+double playbackRate = response.get("playbackRate").getAsDouble();
+System.out.println("playback rate is " + playbackRate);
+
+JsonObject params = new JsonObject();
+params.addProperty("playbackRate", playbackRate / 2);
+client.send("Animation.setPlaybackRate", params);
+```
## async method: CDPSession.detach
* since: v1.8
@@ -63,7 +76,6 @@ send messages.
## async method: CDPSession.send
* since: v1.8
-* langs: js, python, csharp
- returns: <[Object]>
## async method: CDPSession.send
@@ -71,9 +83,13 @@ send messages.
* langs: csharp
- returns: <[JsonElement?]>
+## async method: CDPSession.send
+* since: v1.37
+* langs: java
+- returns: <[JsonObject]>
+
### param: CDPSession.send.method
* since: v1.8
-* langs: js, python, csharp
- `method` <[string]>
Protocol method name.
@@ -93,6 +109,14 @@ Optional method parameters.
Optional method parameters.
+### param: CDPSession.send.params
+* since: v1.37
+* langs: java
+ - alias-java: args
+- `params` ?<[JsonObject]>
+
+Optional method parameters.
+
## method: CDPSession.event
* since: v.1.30
* langs: csharp
@@ -105,4 +129,42 @@ Returns an event emitter for the given CDP event name.
* langs: csharp
- `eventName` <[string]>
-CDP event name.
\ No newline at end of file
+CDP event name.
+
+## method: CDPSession.on
+* since: v1.37
+* langs: java
+
+Register an event handler for events with the specified event name.
+The given handler will be called for every event with the given name.
+
+### param: CDPSession.on.eventName
+* since: v1.37
+- `eventName` <[string]>
+
+CDP event name.
+
+### param: CDPSession.on.handler
+* since: v1.37
+- `handler` <[function]\([JsonObject]\)>
+
+Event handler.
+
+## method: CDPSession.off
+* since: v1.37
+* langs: java
+
+Unregister an event handler for events with the specified event name.
+The given handler will not be called anymore for events with the given name.
+
+### param: CDPSession.off.eventName
+* since: v1.37
+- `eventName` <[string]>
+
+CDP event name.
+
+### param: CDPSession.off.handler
+* since: v1.37
+- `handler` <[function]\([JsonObject]\)>
+
+Event handler.