ddp_utils.browser.facade.protocols¶
import ddp_utils.browser.facade.protocols
Backend-neutral WebDriver BiDi protocol facade.
- class ddp_utils.browser.facade.protocols.BrowserBiDi(browser: Browser)¶
Bases:
objectExpose synchronous WebDriver BiDi only when a backend supplies it.
Parameters
Name
Type
Description
browser
Owning browser facade.
Note
Selenium’s standard
bidi_connection()is asynchronous and is not silently driven by a hidden event loop. A provider must expose a synchronousexecute_bidiboundary to satisfy this facade.Examples
Check runtime support before issuing a raw command:
if browser.bidi.available: browser.bidi.cmd("session.status")
Bind BiDi capability checks to one browser session.
Parameters
Name
Type
Description
browser
Owning browser facade.
Examples
Browser creates this service once:
bidi = BrowserBiDi(browser)
- property available: bool¶
Return whether a synchronous raw BiDi transport is available.
Returns
Trueonly when the backend and native driver support it.Examples
Avoid assuming that Firefox automatically means synchronous BiDi:
assert isinstance(browser.bidi.available, bool)
- cmd(method: str, params: dict[str, Any] | None = None, *, required: bool = False) CapabilityResult[Any]¶
Execute one synchronous raw BiDi command.
Parameters
Name
Type
Description
method
str
Fully qualified BiDi method.
params
dict[str, Any] | None
Optional command parameters.
required
bool
Raise instead of returning unsupported.
Returns
Type
Description
CapabilityResult[Any]
Structured command result.
Raises
Exception
Description
The native transport rejects the command.
Synchronous BiDi is required but absent.
Examples
Request session status:
status = browser.bidi.cmd("session.status")
- subscribe(events: str | Iterable[str], callback: Callable[[...], Any] | None = None) CapabilityResult[BrowserSubscription]¶
Subscribe to one or more BiDi events.
Parameters
Name
Type
Description
events
str | Iterable[str]
Event name or iterable of event names.
callback
Callable[[...], Any] | None
Optional callback receiving native payloads.
Returns
Type
Description
Subscription capability result.
Examples
Subscribe to log events:
result = browser.bidi.subscribe("log.entryAdded", callback)
- unsubscribe(subscription: BrowserSubscription) None¶
Remove one BiDi subscription idempotently.
Parameters
Name
Type
Description
subscription
Subscription returned by
subscribe().Raises
Exception
Description
Native cleanup fails.
Examples
Remove a log subscription:
browser.bidi.unsubscribe(subscription)
- close() None¶
Remove every owned BiDi subscription.
Examples
Browser lifecycle cleanup calls this automatically:
browser.bidi.close()