browsectl
Browser-agnostic automation for AI agents.
A lightweight CLI that lets AI agents (or humans) drive a real browser session: navigate, screenshot, click, type, extract DOM, and evaluate JavaScript. Designed so that agents can see client-side-rendered pages (like LinkedIn) that aren't curl-friendly.
How it works
You launch your browser with remote debugging enabled. browsectl connects to it and sends commands over the browser's native automation protocol. The agent takes screenshots to "see" the page and decides what to do next. When it hits a CAPTCHA or 2FA wall, it tells you and waits.
The core is browser-agnostic. Concrete browser support is provided by swappable backends (currently: CDP for Chrome/Chromium).
Requirements
- Python 3.14+
- Chrome or Chromium (for the CDP backend)
Installation
git clone <repo-url>
cd browsectl
python -m venv .venv
.venv/bin/pip install poetry
.venv/bin/poetry install
Quick start
1. Launch and connect (one step)
browsectl -s <session> launch
This auto-assigns a free port, starts Chrome with its own profile at ~/.browsectl/profiles/<session>/, waits for CDP readiness, connects, and saves the session. The port is stored in the session file so all subsequent commands find it automatically. Logins persist across runs. Your existing Chrome windows are unaffected.
You can also specify a port explicitly if needed:
browsectl -s <session> launch <port>
If the explicit port is already in use, launch fails immediately with a clear error.
For slow-starting environments, override the CDP readiness timeout (default 15s):
browsectl -s <session> launch --timeout 30
2. Use it
Every command requires -s <session>:
browsectl -s <session> goto "https://example.com"
browsectl -s <session> screenshot # saves screenshot.png
browsectl -s <session> screenshot /tmp/page.png # custom path
browsectl -s <session> info # current URL and title
browsectl -s <session> html "h1" # extract innerHTML
browsectl -s <session> eval "document.title" # run JavaScript
browsectl -s <session> click "#login-button" # click by CSS selector
browsectl -s <session> type "#email" "me@example.com"
browsectl -s <session> scroll 500 # scroll down 500px
browsectl -s <session> scroll -300 # scroll up 300px
browsectl -s <session> wait ".results" 10 # wait for element (10s timeout)
browsectl -s <session> tabs # list open tabs
browsectl -s <session> newtab "https://github.com" # open new tab
browsectl -s <session> switchtab <tab-id> # switch to tab (ID from 'tabs')
browsectl -s <session> clear-cookies # clear all browser cookies
3. Manage sessions
browsectl sessions # list all sessions and their status
browsectl -s <session> stop # kill Chrome and remove the session
browsectl stop-all # stop all sessions at once
browsectl profiles # list profile directories
browsectl profiles --prune # remove orphaned profile directories
sessions shows each session's name, host:port, PID, and whether the process is running, dead, or external (connected manually, no PID tracked).
Connecting to an existing browser
If Chrome is already running with --remote-debugging-port, use connect instead of launch:
browsectl -s <session> connect <host> <port>
Both host and port are required.
Multiple sessions
Run multiple independent browser sessions simultaneously. Each gets its own auto-assigned port:
browsectl -s <session-a> launch
browsectl -s <session-b> launch
browsectl -s <session-a> goto "https://example.com"
browsectl -s <session-b> goto "https://github.com"
Each session gets its own Chrome process, profile directory, cookies, and localStorage. Ports are auto-assigned so agents never clash. Use browsectl sessions to see all active sessions, and browsectl -s <session> stop to shut one down. See docs/multi-session.md for details.
Backend selection
browsectl -s <session> -b cdp goto "https://example.com" # explicit (default)
Available backends: cdp. The architecture supports adding others (WebDriver, Marionette, etc.) without changing the core.
Architecture
Hexagonal / ports-and-adapters. The core never imports a concrete browser adapter.
browsectl/
models.py # domain types (PageInfo, Screenshot, Tab, etc.)
ports.py # function signature contracts, generic over Session
gateway.py # BrowserGateway[S] -- frozen bundle of port functions
core.py # command dispatch, browser-agnostic
main.py # CLI entry point, wiring
adapters/
cdp.py # Chrome DevTools Protocol implementation
Per-site guides
docs/sites/ contains navigation guides for specific websites. Each guide documents working selectors, SPA quirks, authentication patterns, and step-by-step browsectl workflows for that site. Selectors are timestamped since sites change their DOM frequently.
Use docs/sites/_template.md as a starting point for new guides.
Development
.venv/bin/pytest tests/ -v # run tests
.venv/bin/mypy browsectl/ # type check (strict)
.venv/bin/ruff check browsectl/ # lint
License
MIT. See LICENSE.
Metadata
Release files for browsectl 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| browsectl-0.2.3.tar.gz | 18.8 kB | Without provenance | Details for browsectl-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| browsectl-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for browsectl-0.2.3-py3-none-any.whl |
Total release size: 39.4 kB
Release files / browsectl-0.2.3.tar.gz
| Download URL | browsectl-0.2.3.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8671699b6c79589528b75b03f7a5a8a6dcecc3c44d2ddca02c84f1426218233d
|
|
BLAKE2b-256 checksum How to use checksums |
5ecf1e5f46fbc6f0c71df154b6649f49f34c8f9d9ef1c9110df50e00256f1770
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.14.8 Linux/6.17.0-1022-azure
|
Release files / browsectl-0.2.3-py3-none-any.whl
| Download URL | browsectl-0.2.3-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31bf262e992b040efb57ebe7cd0ebc500c6be364f0558852d234476e80c46acb
|
|
BLAKE2b-256 checksum How to use checksums |
669ae6235149b919405b8029729ef650815add794648bb4426178b0c7ec5d9d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.14.8 Linux/6.17.0-1022-azure
|
Security for browsectl 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.