English · Java
Appearance
English · Java
Appearance
The WebSocket class represents WebSocket connections within a page. It provides the ability to inspect and manipulate the data being transmitted and received.
If you want to intercept or modify WebSocket frames, consider using WebSocketRoute.
Indicates that the web socket has been closed.
Returns
booleanContains the URL of the WebSocket.
Returns
stringPerforms 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.
Arguments
predicate function(WebSocketFrame): boolean (optional) Added in: v1.9
Receives the WebSocketFrame object and resolves to truthy value when the waiting should resolve.
timeout float (optional) Added in: v1.9
Maximum time to wait for in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the browserContext.setDefaultTimeout().
callback Runnable Added in: v1.9
Callback that performs the action triggering the event.
Returns
WebSocketFramePerforms 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.
Arguments
predicate function(WebSocketFrame): boolean (optional) Added in: v1.9
Receives the WebSocketFrame object and resolves to truthy value when the waiting should resolve.
timeout float (optional) Added in: v1.9
Maximum time to wait for in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the browserContext.setDefaultTimeout().
callback Runnable Added in: v1.9
Callback that performs the action triggering the event.
Returns
WebSocketFrameFired when the websocket closes.
Event data
WebSocketFired when the websocket receives a frame.
Event data
WebSocketFrameFired when the websocket sends a frame.
Event data
WebSocketFrameFired when the websocket has an error.
Event data
string