Native browser automation with typed Python APIs and before-and-after evidence.
Documentation · Get started · Examples · PyPI · Issues
Control browsers and iframe applications from Python with the native [`agent-browser`](https://github.com/vercel-labs/agent-browser) engine. Bind page and frame handles, act on inspected elements, capture model-ready images, and retain before-and-after evidence. > **Alpha:** The public API and native integration can change between minor > releases. Pin a version for production automation. ## Get started ```bash python -m pip install pyagentbrowser ``` Requires Python 3.11 through 3.14. Local browsers run headlessly by default. The first launch finds Chrome or Chromium, or downloads [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/) when needed. ```python from agentbrowser import Browser with Browser.launch() as browser: browser.page.set_content( "" ) snapshot = browser.page.observe() result = snapshot.one(role="button", name="Run").click() print(result.after.one(role="button").name) print(result.diff.changed) ``` ```text Done True ``` `page.observe()` captures a `Snapshot` of the page's accessible elements. Selecting a button returns a `Ref`. Clicking it returns an `ActionResult` with `before`, `after`, and `diff`. Use [`page.find`](docs/guides/interact.md) for live element queries and [`page.frames`](docs/guides/interact.md#work-in-a-child-frame) for embedded applications. ## Browser workflows - **Inspect and act.** Navigate pages, fill forms, read documents, and capture screenshots and PDFs through typed namespaces. - **Keep document scope.** Bind an exact page or frame so observation, evaluation, waits, scrolling, capture, and ref actions share one target. - **Deliver evidence.** Read screenshot bytes and MIME metadata, and inspect structured snapshots and action results. - **Manage sessions.** Launch a browser or attach to an existing one. Work with tabs, cookies, saved state, and explicit cleanup. - **Control actions.** Configure domain restrictions and confirmation policy for operations through the native engine. - **Replay recorded tasks.** Record a task once as a [saved flow](docs/guides/flows.md), then run its requests again with new parameters. - **Compose in Python.** Use synchronous or asynchronous controllers, agent skills, and the complete engine protocol through `browser.native`. ## Documentation [Get started](docs/getting-started.md) · [Concepts](docs/concepts/runtime-model.md) · [Action evidence](docs/concepts/evidence.md) · [Code-mode integration](docs/guides/code-mode.md) · [Safety](docs/concepts/safety.md) · [API reference](docs/reference/browser.md) · [Troubleshooting](docs/troubleshooting.md) The [documentation site](https://peter-gy.github.io/pyagentbrowser/) covers browser workflows, optional packages, supported platforms, and integrations. See [examples](examples/) for Python scripts and [Contributing](CONTRIBUTING.md) for development setup and checks. ## License pyagentbrowser is licensed under the [Apache License 2.0](LICENSE). See [NOTICE](NOTICE) for bundled software attribution.