WebSocket
The WebSocket class represents websocket connections in the page.
- webSocket.on('close')
- webSocket.on('framereceived')
- webSocket.on('framesent')
- webSocket.on('socketerror')
- webSocket.isClosed()
- webSocket.url()
- webSocket.waitForEvent(event[, optionsOrPredicate, options])
webSocket.on('close')
Added in: v1.8- type: <WebSocket>
Fired when the websocket closes.
webSocket.on('framereceived')
Added in: v1.9Fired when the websocket receives a frame.
webSocket.on('framesent')
Added in: v1.9Fired when the websocket sends a frame.
webSocket.on('socketerror')
Added in: v1.9- type: <String>
Fired when the websocket has an error.
webSocket.isClosed()
Added in: v1.8Indicates that the web socket has been closed.
webSocket.url()
Added in: v1.8Contains the URL of the WebSocket.
webSocket.waitForEvent(event[, optionsOrPredicate, options])
Added in: v1.8event
<string> Event name, same one would pass intowebSocket.on(event)
.#optionsOrPredicate?
<function|Object> Either a predicate that receives an event or an options object. Optional.#predicate
<function> receives the event data and resolves to truthy value when the waiting should resolve.timeout?
<number> 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).
options?
<Object>- returns:Promise<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.