ddp_utils.browser.backends.selenium.backend

import ddp_utils.browser.backends.selenium.backend

Concrete Selenium and SeleniumBase backend selection.

class ddp_utils.browser.backends.selenium.backend.SeleniumBrowserBackend(product: BrowserProduct | str, *, provider: str, launcher: SeleniumBrowserLauncher | None = None)

Bases: BrowserBackend

Create a standard Selenium or SeleniumBase managed session.

Parameters

Name

Type

Description

product

BrowserProduct | str

Browser product implemented by this backend instance.

provider

str

Concrete selenium or seleniumbase provider.

launcher

SeleniumBrowserLauncher | None

Optional injected lifecycle launcher.

Examples

Create the natural Chrome provider selected by configuration:

backend = SeleniumBrowserBackend("chrome", provider="seleniumbase")

Initialize immutable identity without importing browser dependencies.

Parameters

Name

Type

Description

product

BrowserProduct | str

Browser product implemented by this backend instance.

provider

str

Concrete selenium or seleniumbase provider.

launcher

SeleniumBrowserLauncher | None

Optional injected lifecycle launcher.

Raises

Exception

Description

BrowserConfigurationError

The provider is unsupported.

Examples

Inject a fake launcher for a contract test:

backend = SeleniumBrowserBackend(
    "firefox", provider="selenium", launcher=fake_launcher
)
property descriptor: BackendDescriptor

Return immutable provider identity and potential capabilities.

Returns

Selenium backend descriptor.

Examples

Check CDP potential before startup:

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

Validate, launch, and own one Selenium browser session.

Parameters

Name

Type

Description

config

BrowserConfig

Validated configuration targeting this backend.

Returns

Type

Description

SeleniumBrowserSession

Started Selenium session with exact lifecycle ownership.

Raises

Exception

Description

BrowserConfigurationError

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

BrowserStartupError

Optional dependencies or browser startup fail.

Examples

Start the backend selected by BackendRegistry:

session = backend.start(config)