ddp_utils.browser.contracts

import ddp_utils.browser.contracts

Stable enums and capability descriptors for browser backends.

class ddp_utils.browser.contracts.BrowserTechnology(value)

Bases: _NormalizedEnum

Automation technology used by a managed or attached session.

Examples

Select the Playwright adapter:

technology = BrowserTechnology.PLAYWRIGHT
class ddp_utils.browser.contracts.BrowserProduct(value)

Bases: _NormalizedEnum

Browser product requested by the project.

Examples

Request Firefox independently of the automation technology:

product = BrowserProduct.FIREFOX
class ddp_utils.browser.contracts.IdentityMode(value)

Bases: _NormalizedEnum

Identity policy applied to the concrete browser provider.

Examples

Request a coherent natural identity:

identity = IdentityMode.NATURAL
class ddp_utils.browser.contracts.LaunchMode(value)

Bases: _NormalizedEnum

Ownership and connection mode for the browser process.

Examples

Attach to an explicitly prepared browser process:

mode = LaunchMode.ATTACH
class ddp_utils.browser.contracts.BrowserCapability(value)

Bases: _NormalizedEnum

Stable names for backend features queried by business logic.

Examples

Check the DOM automation capability before preparing a workflow:

capability = BrowserCapability.DOM
class ddp_utils.browser.contracts.BackendDescriptor(name: str, technology: BrowserTechnology | None, product: BrowserProduct, provider: str, capabilities: frozenset[BrowserCapability] = <factory>, metadata: dict[str, ~typing.Any]=<factory>)

Bases: object

Describe one concrete backend and its immutable capabilities.

Parameters

Name

Type

Description

name

str

Stable concrete backend name.

technology

BrowserTechnology | None

Automation technology, or None for native process mode.

product

BrowserProduct

Browser product represented by the backend.

provider

str

Concrete provider such as seleniumbase or camoufox.

capabilities

frozenset[BrowserCapability]

Supported facade capabilities.

metadata

dict[str, Any]

Additional immutable discovery or version information.

Examples

Describe a Camoufox session:

descriptor = BackendDescriptor(
    name="camoufox",
    technology=BrowserTechnology.PLAYWRIGHT,
    product=BrowserProduct.FIREFOX,
    provider="camoufox",
    capabilities=frozenset({BrowserCapability.DOM}),
)
supports(capability: BrowserCapability | str) → bool

Return whether this backend supports a capability.

Parameters

Name

Type

Description

capability

BrowserCapability | str

Capability enum or normalized capability name.

Returns

Type

Description

bool

True when the capability appears in this descriptor.

Raises

Exception

Description

BrowserConfigurationError

The capability name is unknown.

Examples

Check whether raw CDP commands are available:

if descriptor.supports("cdp"):
    browser.cdp.cmd("Network.enable")
classmethod create(*, name: str, technology: BrowserTechnology | str | None, product: BrowserProduct | str, provider: str, capabilities: Iterable[BrowserCapability | str] = (), metadata: dict[str, Any] | None = None) → BackendDescriptor

Create a normalized immutable backend descriptor.

Parameters

Name

Type

Description

name

str

Stable concrete backend name.

technology

BrowserTechnology | str | None

Automation technology, or None for native mode.

product

BrowserProduct | str

Browser product represented by the backend.

provider

str

Concrete provider name.

capabilities

Iterable[BrowserCapability | str]

Supported capabilities.

metadata

dict[str, Any] | None

Optional version and discovery details.

Returns

Type

Description

BackendDescriptor

Normalized backend descriptor.

Raises

Exception

Description

BrowserConfigurationError

Any enum-like value is invalid.

Examples

Create a native process descriptor:

descriptor = BackendDescriptor.create(
    name="native-edge",
    technology=None,
    product="edge",
    provider="system",
    capabilities=("native_process",),
)