70 / 168 · 01 Agent Skills for Browser Automation · Architecture Decision Records for an AI Test Automation Framework← prev⊞ allnext →☰ Read as one page
10.4ADR-004: Fresh Sessions for CI, Reused Named Sessions for Development
Context
The Playwright CLI manages browser sessions in the .playwright-cli/ workspace. Named sessions (-s=name) persist across commands; a session can be closed and a new one opened at any time. The classic trade-off — persistent browser for speed vs fresh browser for isolation — maps onto session lifecycle.
Decision
- Development/local: one long-lived named session, reused across runs — no browser startup cost between iterations, and
--headedwhen you want to watch - CI/CD: a fresh named session per test for isolation, closed when the test ends
Configuration
# Development: reuse one session all afternoon
playwright-cli -s=dev open https://localhost:3000 --headed
# ... iterate ...
# CI: one session per test, torn down after
playwright-cli -s="$TEST_NAME" open "$BASE_URL/login"
# ... test commands with -s="$TEST_NAME" ...
playwright-cli -s="$TEST_NAME" close
Consequences
- (+) Fast feedback during development
- (+) Clean isolation in CI — no state leaks between tests
- (+) Parallel tests come free: each worker uses its own session name
- (-) Reused dev sessions can accumulate state (mitigated by explicit cleanup:
state-save/state-loadfor known-good baselines, or just close and reopen)