The WebSocket class represents websocket connections in the page.
- event: 'close'
- event: 'framereceived'
- event: 'framesent'
- event: 'socketerror'
- webSocket.waitForEvent(event[, optionsOrPredicate])
Fired when the websocket closes.
Fired when the websocket recieves a frame.
Fired when the websocket sends a frame.
- <String> the error message
Fired when the websocket has an error.
- returns: <boolean>
Indicates that the web socket has been closed.
- returns: <string>
Contains the URL of the WebSocket.
event<string> Event name, same one would pass into
optionsOrPredicate<Function|Object> Either a predicate that receives an event or an options object.
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 to
30000(30 seconds). Pass
0to disable timeout. The default value can be changed by using the browserContext.setDefaultTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
- returns: <Promise<Object>> Promise which resolves to the event data value.
Waits for event to fire and passes its value into the predicate function. Resolves when the predicate returns truthy value. Will throw an error if the webSocket is closed before the event is fired.