MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / wait_for

Method wait_for

py/private/cdp.py:246–261  ·  view source on GitHub ↗

Wait for an event of the given type and return it. This is an async context manager, so you should open it inside an async with block. The block will not exit until the indicated event is received.

(self, event_type: type[T], buffer_size=10)

Source from the content-addressed store, hash-verified

244
245 @asynccontextmanager
246 async def wait_for(self, event_type: type[T], buffer_size=10) -> AsyncGenerator[CmEventProxy, None]:
247 """Wait for an event of the given type and return it.
248
249 This is an async context manager, so you should open it inside
250 an async with block. The block will not exit until the indicated
251 event is received.
252 """
253 sender: trio.MemorySendChannel
254 receiver: trio.MemoryReceiveChannel
255 sender, receiver = trio.open_memory_channel(buffer_size)
256 self.channels[event_type].add(sender)
257 proxy = CmEventProxy()
258 yield proxy
259 async with receiver:
260 event = await receiver.receive()
261 proxy.value = event
262
263 def _handle_data(self, data):
264 """Handle incoming WebSocket data.

Callers 3

mutation_eventsMethod · 0.80
add_js_error_listenerMethod · 0.80
add_listenerMethod · 0.80

Calls 2

CmEventProxyClass · 0.85
addMethod · 0.65

Tested by

no test coverage detected