WebSocket
Playwright\WebSocket\WebSocketInterface
Represents a page WebSocket. The socket exposes its URL and browser-emitted lifecycle or frame events. Send frames or wait for socket activity through the active page connection.
Methods
isClosed()
boolIndicates that the web socket has been closed.
function isClosed(): bool
url()
stringContains the URL of the WebSocket.
function url(): string
on()
voidAdds an event listener for a WebSocket event. Supported events: 'close', 'framereceived', 'framesent', 'socketerror'.
function on(string $event, callable $listener): void
once()
voidAdds a one-time event listener for a WebSocket event.
function once(string $event, callable $listener): void
removeListener()
voidRemoves an event listener for a WebSocket event.
function removeListener(string $event, callable $listener): void
waitForEvent()
arrayWaits for event to fire and passes its value into the predicate function.
function waitForEvent(string $event, array|WaitForEventOptions $options = []): array