Class: Playwright::WebSocket
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::WebSocket
- Defined in:
- lib/playwright_api/web_socket.rb
Overview
The ‘WebSocket` class represents WebSocket connections within a page. It provides the ability to inspect and manipulate the data being transmitted and received.
If you want to intercept or modify WebSocket frames, consider using ‘WebSocketRoute`.
Instance Method Summary collapse
-
#closed? ⇒ Boolean
Indicates that the web socket has been closed.
-
#expect_event(event, predicate: nil, timeout: nil, &block) ⇒ Object
Waits for event to fire and passes its value into the predicate function.
-
#off(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#on(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#once(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#url ⇒ Object
Contains the URL of the WebSocket.
-
#wait_for_event(event, predicate: nil, timeout: nil, &block) ⇒ Object
NOTE: In most cases, you should use [‘method: WebSocket.waitForEvent`].
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#closed? ⇒ Boolean
Indicates that the web socket has been closed.
10 11 12 |
# File 'lib/playwright_api/web_socket.rb', line 10 def closed? wrap_impl(@impl.closed?) end |
#expect_event(event, predicate: nil, timeout: nil, &block) ⇒ Object
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
23 24 25 |
# File 'lib/playwright_api/web_socket.rb', line 23 def expect_event(event, predicate: nil, timeout: nil, &block) wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block))) end |
#off(event, callback) ⇒ Object
– inherited from EventEmitter –
45 46 47 |
# File 'lib/playwright_api/web_socket.rb', line 45 def off(event, callback) event_emitter_proxy.off(event, callback) end |
#on(event, callback) ⇒ Object
– inherited from EventEmitter –
39 40 41 |
# File 'lib/playwright_api/web_socket.rb', line 39 def on(event, callback) event_emitter_proxy.on(event, callback) end |
#once(event, callback) ⇒ Object
– inherited from EventEmitter –
51 52 53 |
# File 'lib/playwright_api/web_socket.rb', line 51 def once(event, callback) event_emitter_proxy.once(event, callback) end |
#url ⇒ Object
Contains the URL of the WebSocket.
16 17 18 |
# File 'lib/playwright_api/web_socket.rb', line 16 def url wrap_impl(@impl.url) end |
#wait_for_event(event, predicate: nil, timeout: nil, &block) ⇒ Object
NOTE: In most cases, you should use [‘method: WebSocket.waitForEvent`].
Waits for given ‘event` to fire. If predicate is provided, it passes event’s value into the ‘predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is fired.
33 34 35 |
# File 'lib/playwright_api/web_socket.rb', line 33 def wait_for_event(event, predicate: nil, timeout: nil, &block) wrap_impl(@impl.wait_for_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block))) end |