Package com.microsoft.playwright
Interface WebSocket
- All Known Implementing Classes:
WebSocketImpl
public interface WebSocket
The
WebSocket class represents websocket connections in the page.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionbooleanisClosed()Indicates that the web socket has been closed.voidRemoves handler that was previously added withonClose(handler).voidoffFrameReceived(Consumer<WebSocketFrame> handler) Removes handler that was previously added withonFrameReceived(handler).voidoffFrameSent(Consumer<WebSocketFrame> handler) Removes handler that was previously added withonFrameSent(handler).voidoffSocketError(Consumer<String> handler) Removes handler that was previously added withonSocketError(handler).voidFired when the websocket closes.voidonFrameReceived(Consumer<WebSocketFrame> handler) Fired when the websocket receives a frame.voidonFrameSent(Consumer<WebSocketFrame> handler) Fired when the websocket sends a frame.voidonSocketError(Consumer<String> handler) Fired when the websocket has an error.url()Contains the URL of the WebSocket.waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, Runnable callback) Performs action and waits for a frame to be sent.default WebSocketFramewaitForFrameReceived(Runnable callback) Performs action and waits for a frame to be sent.waitForFrameSent(WebSocket.WaitForFrameSentOptions options, Runnable callback) Performs action and waits for a frame to be sent.default WebSocketFramewaitForFrameSent(Runnable callback) Performs action and waits for a frame to be sent.
-
Method Details
-
onClose
Fired when the websocket closes. -
offClose
Removes handler that was previously added withonClose(handler). -
onFrameReceived
Fired when the websocket receives a frame. -
offFrameReceived
Removes handler that was previously added withonFrameReceived(handler). -
onFrameSent
Fired when the websocket sends a frame. -
offFrameSent
Removes handler that was previously added withonFrameSent(handler). -
onSocketError
Fired when the websocket has an error. -
offSocketError
Removes handler that was previously added withonSocketError(handler). -
isClosed
boolean isClosed()Indicates that the web socket has been closed.- Since:
- v1.8
-
url
String url()Contains the URL of the WebSocket.- Since:
- v1.8
-
waitForFrameReceived
Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is received.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
waitForFrameReceived
WebSocketFrame waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, Runnable callback) Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is received.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
waitForFrameSent
Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is sent.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
waitForFrameSent
Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is sent.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-