uchrom_browser (the web browser)¶
The web browser is the package uchrom-browser (packages/uchrom-browser). Start it with
python -m uchrom_browser STORE (or uchrom_browser.serve()); drive an open browser from Python
with uchrom_browser.connect(). The HTTP API is documented in uchrom_browser/API.md.
Starting a server¶
Driving the browser from Python¶
- uchrom_browser.connect(url: str | None = None, timeout: float = 30.0) Workspace[source]¶
Connect to a running browser:
url> $UCHROM_BROWSER_URL > the last server started > :8765.
- class uchrom_browser.Workspace(url: str | None = None, timeout: float = 30.0)[source]¶
Bases:
objectA connection to a running browser server (and, through it, to its open page).
- call(action: str, /, **args) Any[source]¶
Run one browser action (see
tools()) on the active page and return its result (a dict).
- capture(pane: str | None = None, path: str | None = None) Dict[str, Any][source]¶
Save a PNG of a view (default: the active one) to
path(default: a temporary file).Returns
{"path", "pane", "width", "height", "bytes"}— not the image itself.
- pages() List[Dict[str, Any]][source]¶
Connected browser pages (the first is the one that receives actions).
- class uchrom_browser.BrowserError[source]¶
Bases:
RuntimeErrorThe server or the page refused an action.