Metadata-Version: 2.4
Name: playwrightauthor
Version: 1.0.23
Summary: Your personal, authenticated browser for Playwright, ready in one line of code.
Project-URL: Homepage, https://github.com/twardoch/playwrightauthor
Project-URL: Bug Tracker, https://github.com/twardoch/playwrightauthor/issues
Author-email: Adam Twardoch <adam+github@twardoch.com>
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Requires-Dist: fire
Requires-Dist: html2text>=2025.4.15
Requires-Dist: httpx>=0.28.1
Requires-Dist: loguru
Requires-Dist: platformdirs
Requires-Dist: playwright
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: psutil
Requires-Dist: requests
Requires-Dist: rich
Requires-Dist: tomli-w>=1.2.0
Description-Content-Type: text/markdown

---
this_file: README.md
---

# PlaywrightAuthor

PlaywrightAuthor gives Python Playwright scripts a persistent, authenticated Chrome for Testing browser.

It finds or installs Chrome for Testing, launches it with a persistent user profile and Chrome DevTools Protocol port, and returns a normal Playwright `Browser`. You log in once in the visible browser; later scripts reuse the same cookies and local browser state.

```python
from playwrightauthor import Browser

with Browser(profile="google-primary", service="Gemini") as browser:
    page = browser.get_page()
    page.goto("https://gemini.google.com/")
    print(page.title())
```

## Install

```bash
uv add playwrightauthor
npx @puppeteer/browsers install chrome@stable
```

The package uses Chrome for Testing, not a normal Chrome user profile. Multiple profiles can run at the same time because each profile receives a stable CDP debug port.

## First sign-in (once per profile)

```bash
playwrightauthor run --profile google-primary --service Gemini
```

A visible Chrome window opens. Sign in. The session is saved to the profile directory and reused on every subsequent script run.

## CLI

```bash
playwrightauthor run --profile google-primary --service Gemini
playwrightauthor run --profile google-secondary --service NotebookLM
playwrightauthor status --profile google-primary
playwrightauthor profile list
playwrightauthor profile show --name google-primary
```

When a browser opens for sign-in, consent, captcha, or another manual step, PlaywrightAuthor shows a small `dialognano` prompt describing the service, profile, and task. Suppress it from Python with `suppress_dialog=True` or from the CLI with `--suppress-dialog`.

## Python API

```python
from playwrightauthor import Browser, AsyncBrowser

with Browser(profile="work", suppress_dialog=True) as browser:
    page = browser.get_page()
    page.goto("https://github.com/")
```

`Browser` and `AsyncBrowser` accept `profile`, `service`, `task`, `verbose`, and `suppress_dialog`.

## Documentation

Practical setup, CLI, profile, API, architecture, and troubleshooting guides live in [docs/](docs/).

Local docs preview:

```bash
cd docs
bundle install
bundle exec jekyll serve
```

## Development

```bash
uv run ruff check --fix src tests
uv run ruff format src tests
uvx hatch test          # runs offline in < 1 s, no Chrome needed
```

Run only the slow browser-integration tests (requires Chrome):

```bash
uv run pytest -m slow
```
