Class: Playwright::CDPSession

Inherits:
PlaywrightApi show all
Defined in:
lib/playwright_api/cdp_session.rb

Overview

  • extends: [EventEmitter]

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:

“‘python sync client = page.context.new_cdp_session(page) client.send(“Animation.enable”) client.on(“Animation.animationCreated”, lambda: print(“animation created!”)) response = client.send(“Animation.getPlaybackRate”) print(“playback rate is ” + str(response)) client.send(“Animation.setPlaybackRate”,

playbackRate: response["playbackRate"] / 2

) “‘

Instance Method Summary collapse

Methods inherited from PlaywrightApi

#initialize, unwrap, wrap

Constructor Details

This class inherits a constructor from Playwright::PlaywrightApi

Instance Method Details

#detachObject

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



28
29
30
# File 'lib/playwright_api/cdp_session.rb', line 28

def detach
  wrap_impl(@impl.detach)
end

#off(event, callback) ⇒ Object

– inherited from EventEmitter –



38
39
40
# File 'lib/playwright_api/cdp_session.rb', line 38

def off(event, callback)
  event_emitter_proxy.off(event, callback)
end

#on(event, callback) ⇒ Object

– inherited from EventEmitter –



50
51
52
# File 'lib/playwright_api/cdp_session.rb', line 50

def on(event, callback)
  event_emitter_proxy.on(event, callback)
end

#once(event, callback) ⇒ Object

– inherited from EventEmitter –



44
45
46
# File 'lib/playwright_api/cdp_session.rb', line 44

def once(event, callback)
  event_emitter_proxy.once(event, callback)
end

#send_message(method, params: nil) ⇒ Object



32
33
34
# File 'lib/playwright_api/cdp_session.rb', line 32

def send_message(method, params: nil)
  wrap_impl(@impl.send_message(unwrap_impl(method), params: unwrap_impl(params)))
end