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, format: str | None = None) Dict[str, Any][source]¶
Save a view (default: the active one) to
path(default: a temporary file).formatis"png"(pixels, as on screen),"svg"or"pdf"(editable vectors for Illustrator / Inkscape); by default it follows the suffix ofpath, else PNG. Returns{"path", "pane", "format", "width", "height", "bytes", "notes"}— not the image itself;noteslists what the vector file approximates (e.g. 3-D tubes as strokes).
- 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.