Browser.connect() opens it and
performs the DCP handshake.
Browser.connect()
Open a session’s control socket and return a Browser.
| Parameter | Type | Default | Description |
|---|---|---|---|
control_url | str | None | HALYARD_CONTROL_URL | The session’s control URL. Raises ValueError when neither is set. |
timeout | float | 60.0 | Seconds to wait for any one reply before giving up. Locator and page timeouts are separate and shorter. |
client | str | None | None | A short lowercase name (up to 32 characters) for an extra connection beside the main one. |
Browser.
Raises NotConnectedError when the socket can’t open, for any reason: a
refused or expired token, an ended session, or a network failure. The message
says which. TimeoutError when the handshake gets no reply within timeout.
One connection per session
A session keeps one driver connection. Opening a second one replaces the first, which is closed, so two scripts can’t fight over the same page by accident. To keep a second connection open beside the first, name it:Getting a control URL
Inside a Halyard sandbox,HALYARD_CONTROL_URL is set for you. Elsewhere, start
a session with the session client and your API key:
Client()
The session client. Reads the key from HALYARD_API_KEY when api_key is omitted.
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | HALYARD_API_KEY | Your API key. |
base_url | str | None | HALYARD_BASE_URL, then https://api.dominuslabs.com | The API’s origin, such as https://api.example.com, without /api/v1: the client adds the path. |
timeout | float | 60.0 | HTTP timeout in seconds. |
HalyardError: UnauthorizedError for 401 and 403,
ConflictError for 409, InvalidArgsError for 400 and 422. A network failure
raises the httpx exception underneath, such as httpx.ConnectError.
client.browsers.create()
Start a browser session and return once it is ready to drive (up to 60 seconds).
| Parameter | Type | Default | Description |
|---|---|---|---|
viewport | dict | None | 1920 x 1080 | {"width", "height", "pixel_ratio"} in CSS pixels. |
tier | str | None | "standard" | Live-view video quality: standard, high or extra_high. |
telemetry | bool | None | True | False turns off the session’s event stream. |
BrowserSession, with id, status, control_url and the full
response in data.
client.browsers.get() and client.browsers.stop()
session.connect()
Open the session’s control socket: Browser.connect(session.control_url, timeout=timeout).
Browser.
session.stop() and session.refresh()
stop() ends the session. refresh() re-reads it so status and data are current.