The [WebSocket] class represents websocket connections in the page.
- type: <[WebSocket]>
Fired when the websocket closes.
- type: <[Object]>
payload
<[string]|[Buffer]> frame payload
Fired when the websocket recieves a frame.
- type: <[Object]>
payload
<[string]|[Buffer]> frame payload
Fired when the websocket sends a frame.
- type: <[String]>
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.
- langs: csharp, js, python
- alias-python: expect_event
- returns: <[any]>
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.
event
<[string]>
Event name, same one would pass into webSocket.on(event)
.
- langs: js
optionsOrPredicate
<[function]|[Object]>predicate
<[function]> receives the event data and resolves to truthy value when the waiting should resolve.timeout
<[float]> maximum time to wait for in milliseconds. Defaults to30000
(30 seconds). Pass0
to disable timeout. The default value can be changed by using the [method: BrowserContext.setDefaultTimeout
].
Either a predicate that receives an event or an options object. Optional.
- langs: csharp, java
- 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.
predicate
<[function]([WebSocketFrame]):[bool]>
Receives the [WebSocketFrame] object and resolves to truthy value when the waiting should resolve.
- langs: csharp, java
- 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.
predicate
<[function]([WebSocketFrame]):[bool]>
Receives the [WebSocketFrame] object and resolves to truthy value when the waiting should resolve.