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

Method open_session

py/private/cdp.py:423–432  ·  view source on GitHub ↗

Context manager opens a session and enables the "simple" style of calling CDP APIs. For example, inside a session context, you can call ``await dom.get_document()`` and it will execute on the current session automatically.

(self, target_id)

Source from the content-addressed store, hash-verified

421
422 @asynccontextmanager
423 async def open_session(self, target_id) -> AsyncIterator[CdpSession]:
424 """Context manager opens a session and enables the "simple" style of calling CDP APIs.
425
426 For example, inside a session context, you can call ``await
427 dom.get_document()`` and it will execute on the current session
428 automatically.
429 """
430 session = await self.connect_session(target_id)
431 with session_context(session):
432 yield session
433
434 async def connect_session(self, target_id) -> "CdpSession":
435 """Returns a new :class:`CdpSession` connected to the specified target."""

Callers 1

bidi_connectionMethod · 0.80

Calls 2

connect_sessionMethod · 0.95
session_contextFunction · 0.85

Tested by

no test coverage detected