class Playwright::WebSocket

The `WebSocket` class represents websocket connections in the page.

Public Instance Methods

closed?() click to toggle source

Indicates that the web socket has been closed.

# File lib/playwright_api/web_socket.rb, line 6
def closed?
  wrap_impl(@impl.closed?)
end
expect_event(event, predicate: nil, timeout: nil, &block) click to toggle source

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.

# File lib/playwright_api/web_socket.rb, line 17
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) click to toggle source

– inherited from EventEmitter – @nodoc

# File lib/playwright_api/web_socket.rb, line 44
def off(event, callback)
  event_emitter_proxy.off(event, callback)
end
on(event, callback) click to toggle source

– inherited from EventEmitter – @nodoc

# File lib/playwright_api/web_socket.rb, line 38
def on(event, callback)
  event_emitter_proxy.on(event, callback)
end
once(event, callback) click to toggle source

– inherited from EventEmitter – @nodoc

# File lib/playwright_api/web_socket.rb, line 32
def once(event, callback)
  event_emitter_proxy.once(event, callback)
end
url() click to toggle source

Contains the URL of the WebSocket.

# File lib/playwright_api/web_socket.rb, line 11
def url
  wrap_impl(@impl.url)
end
wait_for_event(event, predicate: nil, timeout: nil, &block) click to toggle source

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

# File lib/playwright_api/web_socket.rb, line 26
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

Private Instance Methods

event_emitter_proxy() click to toggle source
# File lib/playwright_api/web_socket.rb, line 48
        def event_emitter_proxy
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
end