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

Implemented in https://github.com/microsoft/playwright-java/pull/1329
This commit is contained in:
Raphi 2023-07-17 19:12:04 +02:00 коммит произвёл GitHub
Родитель 49c1f9eb02
Коммит 2d9cdb6ab4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 66 добавлений и 6 удалений

Просмотреть файл

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

Просмотреть файл

@ -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

Просмотреть файл

@ -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.
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.