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:
BrowserBackendCreate 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
playwrightorcamoufoxprovider.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
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
Validated configuration targeting this backend.
Returns
Type
Description
Started session with exact lifecycle ownership.
Raises
Exception
Description
Technology, product, provider, or launch mode contradicts this backend.
Optional dependencies or startup fail.
Examples
Start the provider selected by
BackendRegistry:session = backend.start(config)