Package com.microsoft.playwright
Interface WebSocket
-
public interface WebSocketTheWebSocketclass represents websocket connections in the page.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classWebSocket.WaitForFrameReceivedOptionsstatic classWebSocket.WaitForFrameSentOptions
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanisClosed()Indicates that the web socket has been closed.voidoffClose(Consumer<WebSocket> handler)Removes 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).voidonClose(Consumer<WebSocket> handler)Fired 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.Stringurl()Contains the URL of the WebSocket.WebSocketFramewaitForFrameReceived(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.WebSocketFramewaitForFrameSent(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 Detail
-
offClose
void offClose(Consumer<WebSocket> handler)
Removes handler that was previously added withonClose(handler).
-
onFrameReceived
void onFrameReceived(Consumer<WebSocketFrame> handler)
Fired when the websocket receives a frame.
-
offFrameReceived
void offFrameReceived(Consumer<WebSocketFrame> handler)
Removes handler that was previously added withonFrameReceived(handler).
-
onFrameSent
void onFrameSent(Consumer<WebSocketFrame> handler)
Fired when the websocket sends a frame.
-
offFrameSent
void offFrameSent(Consumer<WebSocketFrame> handler)
Removes handler that was previously added withonFrameSent(handler).
-
offSocketError
void offSocketError(Consumer<String> handler)
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
default WebSocketFrame waitForFrameReceived(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
-
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
default WebSocketFrame waitForFrameSent(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 sent.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
waitForFrameSent
WebSocketFrame waitForFrameSent(WebSocket.WaitForFrameSentOptions 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 sent.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
-