Skip to content

botonomus.drivers

Driver adapters that attach page automation to a launched browser.

botonomus.drivers

Driver adapters that attach page automation to a launched browser.

Attachment

Bases: Protocol

A driver's live connection to one browser.

context instance-attribute

context: Any

The default browser context, backed by the dedicated profile.

page instance-attribute

page: Any

The initial page.

request_close async

request_close() -> None

Ask the browser to exit gracefully. Never raises on an already-gone browser.

disconnect async

disconnect() -> None

Drop the driver connection without closing the browser.

Driver

Bases: Protocol

Factory for attachments; may hold a shared runtime (e.g. Playwright's).

start async

start() -> None

Start the driver runtime.

Raises:

Type Description
BrowserStartupError

If the driver package is missing or fails to start.

attach async

attach(port: int, timeout: float) -> Attachment

Connect to the browser listening on loopback port.

Parameters:

Name Type Description Default
port int

The browser's --remote-debugging-port.

required
timeout float

Seconds allowed for the connection.

required

stop async

stop() -> None

Release the driver runtime. Idempotent.

NativeAttachment

NativeAttachment(browser: Browser, page: Page)

A native CDP connection to one browser.

Attributes:

Name Type Description
browser

The connected botonomus.cdp.Browser.

context Any

The browser's default context.

page Any

The initial page.

request_close async

request_close() -> None

Send Browser.close; a browser that is already gone is not an error.

disconnect async

disconnect() -> None

Close the websocket.

NativeDriver

Attaches NativeAttachment instances. Holds no shared runtime.

start async

start() -> None

Nothing to start; present for the Driver contract.

attach async

attach(port: int, timeout: float) -> NativeAttachment

Connect over the browser websocket advertised at /json/version.

stop async

stop() -> None

Nothing to stop.

PlaywrightAttachment

PlaywrightAttachment(browser: Any, page: Any)

A Playwright-compatible connection to one browser.

Attributes:

Name Type Description
browser

The Playwright Browser.

context Any

Its default BrowserContext.

page Any

The initial Page.

request_close async

request_close() -> None

Send Browser.close through a browser CDP session, ignoring failures.

disconnect async

disconnect() -> None

Close the Playwright connection, ignoring failures.

PlaywrightDriver

PlaywrightDriver(flavor: PlaywrightFlavor)

Runs one Playwright (or Patchright) runtime shared by all attachments.

Parameters:

Name Type Description Default
flavor PlaywrightFlavor

"playwright" or "patchright".

required

start async

start() -> None

Start the runtime once.

Raises:

Type Description
BrowserStartupError

If the package is not installed or fails to start.

attach async

attach(port: int, timeout: float) -> PlaywrightAttachment

Connect with connect_over_cdp and return the default context's page.

stop async

stop() -> None

Stop the runtime if running.

create_driver

create_driver(name: DriverName) -> Driver

Return the driver adapter for name.

Raises:

Type Description
ConfigurationError

If name is not a known driver.