WebSocket
The WebSocket class represents websocket connections in the page.
- WebSocket.onClose(handler)
- WebSocket.onFrameReceived(handler)
- WebSocket.onFrameSent(handler)
- WebSocket.onSocketError(handler)
- WebSocket.isClosed()
- WebSocket.url()
- WebSocket.waitForFrameReceived([options], callback)
- WebSocket.waitForFrameSent([options], callback)
WebSocket.onClose(handler)
- type: <WebSocket>
Fired when the websocket closes.
WebSocket.onFrameReceived(handler)
- type: <WebSocketFrame>
Fired when the websocket receives a frame.
WebSocket.onFrameSent(handler)
- type: <WebSocketFrame>
Fired when the websocket sends a frame.
WebSocket.onSocketError(handler)
- type: <String>
Fired when the websocket has an error.
WebSocket.isClosed()
Indicates that the web socket has been closed.
WebSocket.url()
Contains the URL of the WebSocket.
WebSocket.waitForFrameReceived([options], callback)
options
<WebSocket.WaitForFrameReceivedOptions
>setPredicate
<Predicate<WebSocketFrame>> Receives the WebSocketFrame object and resolves to truthy value when the waiting should resolve.#setTimeout
<double> Maximum time to wait for in milliseconds. Defaults to30000
(30 seconds). Pass0
to disable timeout. The default value can be changed by using the BrowserContext.setDefaultTimeout(timeout).#
callback
<Runnable> Callback that performs the action triggering the event.#- returns:WebSocketFrame># <
Performs action and waits for a frame to be sent. If predicate is provided, it passes WebSocketFrame value into the predicate
function and waits for predicate(webSocketFrame)
to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is received.
WebSocket.waitForFrameSent([options], callback)
options
<WebSocket.WaitForFrameSentOptions
>setPredicate
<Predicate<WebSocketFrame>> Receives the WebSocketFrame object and resolves to truthy value when the waiting should resolve.#setTimeout
<double> Maximum time to wait for in milliseconds. Defaults to30000
(30 seconds). Pass0
to disable timeout. The default value can be changed by using the BrowserContext.setDefaultTimeout(timeout).#
callback
<Runnable> Callback that performs the action triggering the event.#- returns:WebSocketFrame># <
Performs action and waits for a frame to be sent. If predicate is provided, it passes WebSocketFrame value into the predicate
function and waits for predicate(webSocketFrame)
to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is sent.