GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Playwright for Java
  • Docs
  • API
  • Java
  • Node.js
  • Python
  • .NET
  • Community
  • Classes
  • APIRequestContext
  • APIResponse
  • Browser
  • BrowserContext
  • BrowserType

This view

  • Original page
  • New address

GeezerVison is showing playwright.dev — CDPSession | Playwright Java

This is unreleased documentation for Playwright Java Next version.
For up-to-date documentation, see the latest version (stable).
Version: Next

The CDPSession instances are used to talk raw Chrome Devtools Protocol:

  • protocol methods can be called with session.send method.
  • protocol events can be subscribed to with session.on method.

Useful links:

  • Documentation on DevTools Protocol can be found here: DevTools Protocol Viewer.
  • Getting Started with DevTools Protocol: https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
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);

Methods​

detach​

Added before v1.9 cdpSession.detach

Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to send messages.

Usage

CDPSession.detach();

Returns

  • void#

off​

Added in: v1.37 cdpSession.off

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.

Usage

CDPSession.off(eventName, handler);

Arguments

  • eventName String#

    CDP event name.

  • handler Consumer<JsonObject>#

    Event handler.


on​

Added in: v1.37 cdpSession.on

Register an event handler for events with the specified event name. The given handler will be called for every event with the given name.

Usage

CDPSession.on(eventName, handler);

Arguments

  • eventName String#

    CDP event name.

  • handler Consumer<JsonObject>#

    Event handler.


send​

Added before v1.9 cdpSession.send

Usage

CDPSession.send(method);
CDPSession.send(method, args, options);

Arguments

  • method String#

    Protocol method name.

  • args JsonObject (optional) Added in: v1.37#

    Optional method parameters.

  • options CdpSession.SendOptions (optional)

    • setTimeout double (optional) Added in: v1.65#

      Maximum time in milliseconds to wait for the response. Defaults to 0 - no timeout.

Returns

  • JsonObject#

Events​

onClose(handler)​

Added in: v1.59 cdpSession.onClose(handler)

Emitted when the session is closed, either because the target was closed or session.detach() was called.

Usage

CDPSession.onClose(handler)

Event data

  • CDPSession
  • Methods
    • detach
    • off
    • on
    • send
  • Events
    • onClose(handler)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.