MCPcopy Index your code
hub / github.com/microsoft/playwright-python / handle_ws

Function handle_ws

tests/async/test_route_web_socket.py:354–360  ·  view source on GitHub ↗
(ws: WebSocketRoute)

Source from the content-addressed store, hash-verified

352 log: list[str] = []
353
354 async def handle_ws(ws: WebSocketRoute) -> None:
355 def on_message(message: Union[str, bytes]) -> None:
356 assert isinstance(message, str)
357 log.append(message)
358 ws.send("response")
359
360 ws.on_message(on_message)
361
362 # No trailing slash in the route pattern
363 await page.route_web_socket(f"ws://localhost:{server.PORT}", handle_ws)

Callers

nothing calls this directly

Calls 1

on_messageMethod · 0.45

Tested by

no test coverage detected