konyklabs/claude-plugins/testing-playwright-browser
Claude Code and agent skill by konyklabs/claude-plugins
- community
Checking that the SKILL.md file is still in the repository.
Browser tests with pytest-playwright — the page and context fixtures, role-based locators, web-first assertions, page objects, logging in once and reusing storage state, tracing on failure, network mocking, and running under xdist. Use when writing or fixing in-browser tests, when a test is flaky or slow, when a selector broke, or when auth is repeated in every test.
Install
npx vskill@latest install konyklabs/claude-plugins/testing-playwright-browserSKILL.md
The same SKILL.md was published earlier as konyklabs/claude-plugins/testing-playwright-browser.
Playwright browser tests
Most browser-test cost is not in writing tests; it is in re-running slow, flaky ones. The choices below (locators that wait, assertions that retry, one login per run, a trace on every failure) are what keep the suite fast enough to run on every PR.
Fixtures
pytest-playwright provides them; do not create your own browser.
| fixture | scope | use | |
|---|---|---|---|
page | function | a fresh page in a fresh context per test | |
context | function | the page's context; context.request for API calls | |
new_context | function | factory for a second identity in one test | |
browser | session | one browser per run (per xdist worker) | |
browser_context_args | session | override to set storage_state, viewport, base_url | |
browser_type_launch_args | session | override for slow_mo, channel |
Options come from the CLI or addopts: --browser chromium, --headed, --base-url, --tracing retain-on-failure, --screenshot only-on-failure, --video retain-on-failure, --output test-results. Since pytest-playwright 0.10 the plugin provides --base-url and the base_url fixture itself; the pytest-base-url extra (pytest-playwright[base-url]) is needed only for --verify-base-url. These options apply only to the default page/context; a context from browser.new_context() gets no trace, video or screenshot.
Locators and assertions
Priority from the docs: get_by_role > get_by_text > get_by_label > get_by_test_id > CSS or XPath last. Role locators read like the user sees the page and survive markup changes; a CSS chain is a bug waiting for the next refactor.
expect(...)retries until its timeout (5 s default); a bareasserton
locator.text_content() does not. Web-first assertions are the fix for most "works locally, flaky in CI".
- Never
page.wait_for_timeout(n). Wait for the thing you need:
expect(locator).to_be_visible(), page.wait_for_url(...).
expect.set_options(timeout=10_000)once in conftest when the app is slow;
do not sprinkle timeouts per assertion.
Page objects
One class per page or component; it owns the locators and exposes actions. Tests contain intent, not selectors.
Log in once
storage_state persists cookies and local storage; IndexedDB only when saved with indexed_db=True (opt-in); never session storage. Log in once per run (per worker under xdist: a session fixture runs in each), save the state, load it into every context:
Tests that must start logged out use new_context(storage_state=None).
Network
page.route("**/api/prices", lambda r: r.fulfill(json={"A1": 9.99})) mocks a response; route.abort() blocks (analytics, images); route.fetch() then route.fulfill(response=..., body=...) rewrites a real response. Mock at the edge of the system under test, not inside it: a UI test with every API mocked tests the mocks.
Failure evidence and speed
--tracing retain-on-failurealways. A trace has the DOM, network and
console per step; a screenshot has a moment.
PWDEBUG=1 pytest -s tests/ui -k nameopens the inspector; `playwright
show-trace test-results/.../trace.zip` replays a CI failure.
pytest -n autoruns one browser per worker. Tests must not share
server-side state by name; suffix created records with a uuid.
- Keep
tests/uito what only a browser can verify. Business rules belong in
tests/api or tests/unit where they cost milliseconds.
Fuller fixture code, the CLI table and sources in references/browser-fixtures.md.
Sources
playwright.dev/python/docs: test-runners, locators, test-assertions, auth, network, pom, debug; pytest-xdist how-to; fetched 2026-10-29 (first 2026-09-02; pytest-playwright 0.10.0 current). The auth_state fixture above composes documented pieces (storage_state, browser_context_args); the docs show the pieces, not this exact fixture.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/py-testing/skills/testing-playwright-browser/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/konyklabs/claude-plugins/testing-playwright-browser)