Class: Playwright::CDPSession
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::CDPSession
- Defined in:
- lib/playwright_api/cdp_session.rb,
sig/playwright.rbs
Overview
The CDPSession instances are used to talk raw Chrome Devtools Protocol:
- protocol methods can be called with
session.sendmethod. - protocol events can be subscribed to with
session.onmethod.
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
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["playbackRate"]))
client.send("Animation.setPlaybackRate", {
"playbackRate": response["playbackRate"] / 2
})
Instance Method Summary collapse
-
#detach ⇒ void
Detaches the CDPSession from the target.
-
#off(event, callback) ⇒ Object
-- inherited from EventEmitter --.
-
#on(event, callback) ⇒ Object
-- inherited from EventEmitter --.
-
#once(event, callback) ⇒ Object
-- inherited from EventEmitter --.
- #send_message(method, params: nil) ⇒ Hash[untyped, untyped]
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#detach ⇒ void
This method returns an undefined value.
Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to send messages.
26 27 28 |
# File 'lib/playwright_api/cdp_session.rb', line 26 def detach wrap_impl(@impl.detach) end |
#off(event, callback) ⇒ Object
-- inherited from EventEmitter --
36 37 38 |
# File 'lib/playwright_api/cdp_session.rb', line 36 def off(event, callback) event_emitter_proxy.off(event, callback) end |
#on(event, callback) ⇒ Object
-- inherited from EventEmitter --
48 49 50 |
# File 'lib/playwright_api/cdp_session.rb', line 48 def on(event, callback) event_emitter_proxy.on(event, callback) end |
#once(event, callback) ⇒ Object
-- inherited from EventEmitter --
42 43 44 |
# File 'lib/playwright_api/cdp_session.rb', line 42 def once(event, callback) event_emitter_proxy.once(event, callback) end |
#send_message(method, params: nil) ⇒ Hash[untyped, untyped]
30 31 32 |
# File 'lib/playwright_api/cdp_session.rb', line 30 def (method, params: nil) wrap_impl(@impl.(unwrap_impl(method), params: unwrap_impl(params))) end |