ddp_utils.browser.session¶
import ddp_utils.browser.session
Backend-neutral session ownership and capability access.
- class ddp_utils.browser.session.BrowserSession(backend_session: BackendSession)¶
Bases:
objectOwn one concrete backend session behind a stable neutral lifecycle.
Parameters
Name
Type
Description
backend_session
Started concrete backend session.
Examples
Keep backend-native objects behind an explicit escape hatch:
with browser_session as session: native = session.native
Bind a concrete started session.
Parameters
Name
Type
Description
backend_session
Started concrete backend session.
Examples
Factories create this wrapper after a backend starts:
session = BrowserSession(backend.start(config))
- property descriptor: BackendDescriptor¶
Return immutable backend identity and capabilities.
Returns
Concrete backend descriptor.
Examples
Record the selected provider in diagnostics:
print(session.descriptor.provider)
- property native: Any¶
Return the explicit backend-native escape hatch.
Returns
WebDriver, Playwright page/context bundle, or native process info.
Examples
Use a backend-only operation intentionally:
native = session.native
- property closed: bool¶
Return whether the concrete session is closed.
Returns
Trueafter backend resources are released.Examples
Avoid work after context exit:
if session.closed: return
- capability(capability: BrowserCapability | str) CapabilityResult[BrowserCapability]¶
Return structured support information for one capability.
Parameters
Name
Type
Description
capability
BrowserCapability | str
Capability enum or normalized name.
Returns
Type
Description
Supported result with normalized capability, or an unsupported result with backend identity and a precise reason.
Examples
Check CDP without backend-name branching:
cdp_support = session.capability("cdp")
- close() None¶
Close the concrete backend session idempotently.
Examples
Release browser resources explicitly:
session.close()