GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Playwright for Java
  • Docs
  • API
  • Java
  • Node.js
  • Python
  • .NET
  • Community
  • Classes
  • APIRequestContext
  • APIResponse
  • Browser
  • BrowserContext
  • BrowserType

This view

  • Original page
  • New address

GeezerVison is showing playwright.dev — WebSocket | Playwright Java

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.


Methods​

isClosed​

Added before v1.9 webSocket.isClosed

Indicates that the web socket has been closed.

Usage

WebSocket.isClosed();

Returns

  • boolean#

url​

Added before v1.9 webSocket.url

Contains the URL of the WebSocket.

Usage

WebSocket.url();

Returns

  • String#

waitForFrameReceived​

Added in: v1.10 webSocket.waitForFrameReceived

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.

Usage

WebSocket.waitForFrameReceived(callback);
WebSocket.waitForFrameReceived(callback, options);

Arguments

  • options WebSocket.WaitForFrameReceivedOptions (optional)

    • setPredicate Predicate<WebSocketFrame> (optional) Added in: v1.9#

      Receives the WebSocketFrame object and resolves to truthy value when the waiting should resolve.

    • setTimeout double (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

  • WebSocketFrame#

waitForFrameSent​

Added in: v1.10 webSocket.waitForFrameSent

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.

Usage

WebSocket.waitForFrameSent(callback);
WebSocket.waitForFrameSent(callback, options);

Arguments

  • options WebSocket.WaitForFrameSentOptions (optional)

    • setPredicate Predicate<WebSocketFrame> (optional) Added in: v1.9#

      Receives the WebSocketFrame object and resolves to truthy value when the waiting should resolve.

    • setTimeout double (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

  • WebSocketFrame#

Events​

onClose(handler)​

Added before v1.9 webSocket.onClose(handler)

Fired when the websocket closes.

Usage

WebSocket.onClose(handler)

Event data

  • WebSocket

onFrameReceived(handler)​

Added in: v1.9 webSocket.onFrameReceived(handler)

Fired when the websocket receives a frame.

Usage

WebSocket.onFrameReceived(handler)

Event data

  • WebSocketFrame

onFrameSent(handler)​

Added in: v1.9 webSocket.onFrameSent(handler)

Fired when the websocket sends a frame.

Usage

WebSocket.onFrameSent(handler)

Event data

  • WebSocketFrame

onSocketError(handler)​

Added in: v1.9 webSocket.onSocketError(handler)

Fired when the websocket has an error.

Usage

WebSocket.onSocketError(handler)

Event data

  • String
  • Methods
    • isClosed
    • url
    • waitForFrameReceived
    • waitForFrameSent
  • Events
    • onClose(handler)
    • onFrameReceived(handler)
    • onFrameSent(handler)
    • onSocketError(handler)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.