ddp_utils.browser.backends.playwright.session

import ddp_utils.browser.backends.playwright.session

Owned Playwright and Camoufox session lifecycle.

class ddp_utils.browser.backends.playwright.session.PlaywrightBrowserSession(descriptor: BackendDescriptor, native: PlaywrightNativeObjects)

Bases: object

Own one Playwright-family lifecycle without claiming external processes.

Parameters

Name

Type

Description

descriptor

BackendDescriptor

Immutable concrete backend descriptor.

native

PlaywrightNativeObjects

Explicit native objects and ownership flags.

Examples

Close all owned resources deterministically:

with session:
    session.native.page.goto("https://example.com")

Bind descriptor and native lifecycle resources.

Parameters

Name

Type

Description

descriptor

BackendDescriptor

Immutable backend descriptor.

native

PlaywrightNativeObjects

Native objects returned by the launcher.

Examples

Backends create a session after a complete launch:

session = PlaywrightBrowserSession(descriptor, native)
property descriptor: BackendDescriptor

Return immutable Playwright-family identity and capabilities.

Returns

Concrete backend descriptor.

Examples

Distinguish Camoufox from standard Playwright:

print(session.descriptor.provider)
property native: PlaywrightNativeObjects

Return explicit page, context, browser, runtime, and manager objects.

Returns

Native Playwright-family objects.

Examples

Access a backend-native context intentionally:

context = session.native.context
property closed: bool

Return whether owned resources have been released.

Returns

True after the first close call.

Examples

Confirm deterministic cleanup:

assert session.closed
close() → None

Release only resources owned by this session exactly once.

Attached browser processes and their contexts are not closed. Cleanup errors are reported as resource warnings after all remaining cleanup operations have been attempted.

Examples

Close explicitly outside a context manager:

session.close()