new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

websocket/methods

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

WebSocket.isClosed method

The isClosed method returns a boolean indicating that the WebSocket has been closed. Available since v1.8.

WebSocket.waitForEvent parameters

waitForEvent takes two parameters: event (required string, same as would pass into webSocket.on(event)), and optionsOrPredicate (optional function or Object for JavaScript). When an Object, optionsOrPredicate has properties: predicate (function receiving event data, resolves to truthy value), timeout (float in milliseconds, defaults to 0 - no timeout, can be changed via actionTimeout config or BrowserContext.setDefaultTimeout or Page.setDefaultTimeout), and signal. Available since v1.8.

WebSocket.waitForEvent Python usage example

Python async example: ```python async async with ws.expect_event("framereceived") as event_info: await page.get_by_text("Send message").click() payload = await event_info.value print(payload) ``` Python sync example: ```python sync with ws.expect_event("framereceived") as event_info: page.get_by_text("Send message").click() payload = event_info.value print(payload) ```

WebSocket.waitForFrameSent method

The waitForFrameSent async method performs an action and waits for a frame to be sent. If a predicate is provided, it passes the WebSocketFrame value into the predicate function and waits for predicate(webSocketFrame) to return a truthy value. Throws an error if the WebSocket or Page is closed before the frame is sent. Returns a WebSocketFrame. Available since v1.10 for Java.

WebSocket.waitForFrameSent parameters

waitForFrameSent takes a callback parameter (for Java), and options: predicate (function receiving WebSocketFrame, returns boolean), timeout (float in milliseconds), and signal. Available since v1.9.

WebSocket.waitForEvent2 method

The waitForEvent2 async method waits for a given event to fire. If a predicate is provided, it passes the event's value into the predicate function and waits for predicate(event) to return a truthy value. Throws an error if the socket is closed before the event is fired. Returns any value. In Python, this method is aliased as wait_for_event. Available since v1.8 for Python. Note: In most cases, you should use waitForEvent instead.

WebSocket.waitForEvent2 parameters

waitForEvent2 takes parameters: event (required string, same as would pass into webSocket.on(event)), predicate (optional function receiving event, resolves to truthy value), timeout (optional float in milliseconds), and signal. Available since v1.8.

Give your agent this brain