ddp_utils.browser.backends.playwright.backend

import ddp_utils.browser.backends.playwright.backend

Concrete Playwright and Camoufox backend selection.

class ddp_utils.browser.backends.playwright.backend.PlaywrightBrowserBackend(product: BrowserProduct | str, *, provider: str, launcher: PlaywrightBrowserLauncher | None = None)

Bases: BrowserBackend

Create a standard Playwright or natural Camoufox browser session.

Parameters

Name

Type

Description

product

BrowserProduct | str

Browser product implemented by this backend instance.

provider

str

Concrete playwright or camoufox provider.

launcher

PlaywrightBrowserLauncher | None

Optional injected lifecycle launcher.

Examples

Create the natural Firefox provider:

backend = PlaywrightBrowserBackend("firefox", provider="camoufox")

Initialize backend identity without importing optional dependencies.

Parameters

Name

Type

Description

product

BrowserProduct | str

Browser product implemented by this backend.

provider

str

Concrete provider name.

launcher

PlaywrightBrowserLauncher | None

Optional lifecycle launcher replacement.

Raises

Exception

Description

BrowserConfigurationError

The provider or product is contradictory.

Examples

Inject a fake launcher for a contract test:

backend = PlaywrightBrowserBackend(
    "chrome", provider="playwright", launcher=fake_launcher
)
property descriptor: BackendDescriptor

Return immutable provider identity and potential capabilities.

Returns

Playwright-family backend descriptor.

Examples

Check whether raw CDP can be exposed:

assert backend.descriptor.supports("cdp")
start(config: BrowserConfig) → PlaywrightBrowserSession

Validate, launch, and own one Playwright-family session.

Parameters

Name

Type

Description

config

BrowserConfig

Validated configuration targeting this backend.

Returns

Type

Description

PlaywrightBrowserSession

Started session with exact lifecycle ownership.

Raises

Exception

Description

BrowserConfigurationError

Technology, product, provider, or launch mode contradicts this backend.

BrowserStartupError

Optional dependencies or startup fail.

Examples

Start the provider selected by BackendRegistry:

session = backend.start(config)