playwright

Playwright browser automation API, web scraping, and tooling. Covers locator strategies, assertions, API testing, stealth mode, anti-bot bypass, authenticated sessions, screenshots/PDFs, Docker deployment, configuration, debugging, and MCP integration with AI agents. Prevents documented errors including CI timeout hangs, extension testing failures, and navigation issues. Use when automating browsers, scraping protected sites, bypassing bot detection, generating screenshots/PDFs, configuring Playwright Test, troubleshooting Playwright errors, or learning Playwright API patterns. For E2E test architecture, Page Object Models, CI sharding strategies, or test organization patterns, use the e2e-testing skill instead.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "playwright" with this command: npx skills add oakoss/agent-skills/oakoss-agent-skills-playwright

Playwright

Overview

Playwright is a browser automation framework for Node.js and Python supporting Chromium, Firefox, and WebKit with a single API. It provides auto-waiting, web-first assertions, and full test isolation for reliable end-to-end testing.

When to use: Browser automation, web scraping, screenshot/PDF generation, API testing, configuring Playwright Test, troubleshooting Playwright errors, stealth mode and anti-bot bypass.

When NOT to use: Simple HTTP requests (use fetch), unit testing (use Vitest/Jest), serverless scraping at scale (consider Cloudflare Browser Rendering). For E2E test architecture (Page Object Models, CI sharding, test organization, authentication patterns), use the e2e-testing skill.

Quick Reference

PatternAPI / ConfigKey Points
Basic testtest('name', async ({ page }) => {})Auto-wait, web-first assertions, test isolation
Locatorpage.getByRole() / page.locator()Prefer role/label/text selectors over CSS
Assertionexpect(locator).toBeVisible()Auto-retrying, configurable timeout
API testingrequest fixture / apiRequestContextSend HTTP requests, validate responses
Aria snapshotexpect(locator).toMatchAriaSnapshot()Validate accessibility tree structure via YAML
Class assertionexpect(locator).toContainClass('active')Match individual CSS class names (v1.52+)
Visible filterlocator.filter({ visible: true })Match only visible elements (v1.51+)
Test steptest.step('name', async (step) => {})Timeout, skip, and attachments (v1.50+)
Stealth modeplaywright-extra + stealth pluginPatches 20+ detection vectors
Authenticated sessioncontext.cookies() + addCookies()Save/restore cookies and IndexedDB for persistence
Screenshotpage.screenshot({ fullPage: true })Wait for key elements to load first
PDF generationpage.pdf({ format: 'A4' })Chromium only, set printBackground: true
Clock APIpage.clockFreeze, fast-forward, or simulate time in tests
A11y assertionstoHaveAccessibleName, toHaveRoleNative assertions without axe-core dependency
Viewport assertionexpect(locator).toBeInViewport()Assert element is within the visible viewport
Changed tests only--only-changed=$GITHUB_BASE_REFRun only test files changed since base branch
Dockermcr.microsoft.com/playwright:v1.58.2-nobleUse --init --ipc=host flags
Debug methodspage.consoleMessages() / page.requests() (v1.56+)No event listeners needed
SpeedboardHTML reporter (v1.57+)Identifies slow tests and bottlenecks
Playwright Agentsnpx playwright init-agentsPlanner, generator, healer for LLM-driven testing
Flaky test detection--fail-on-flaky-tests (v1.50+)Exit code 1 on flaky tests in CI
Modify live responsesroute.fetch() + route.fulfill()Intercept real response, tweak JSON, return it
Soft assertionsexpect.soft(locator)Don't stop test on failure, report all at end
Retry blockexpect(async () => {}).toPass()Default timeout is 0 (forever) — always set one
Custom matchersexpect.extend() / mergeExpects()Define or combine custom assertion methods
Actionability matrixPer-action auto-wait checksclick: all 5 checks, fill: 3, focus/blur: none
Test modifierstest.fixme() / test.fail() / test.slow()fixme=skip+track, fail=assert failure, slow=3x
Parallel modestest.describe.configure({ mode: 'serial' })serial, parallel, or default per-describe block
Teardown projectsteardown option on setup projectsAuto-cleanup after all dependents finish

Common Mistakes

MistakeCorrect Pattern
Using CSS selectors over role selectorsPrefer getByRole, getByLabel, getByText for resilience
Not closing browserAlways await browser.close() in finally block
Using setTimeout for waitsUse locator auto-wait or waitForLoadState
page.pause() left in CI codeGuard with if (!process.env.CI) — hangs CI indefinitely
Clicking without waitingUse locator().click() with built-in auto-wait
Shared state between testsEach test gets fresh context via fixtures
Testing implementation detailsAssert user-visible behavior, not DOM structure
Hardcoded waits for dynamic contentWait for selector appearance or content stabilization
Missing await on assertionsAll expect() assertions return promises — must be awaited
Same user agent for all scrapingRotate user agents for high-volume scraping
Using setTimeout for time-dependent testsUse page.clock API to freeze/fast-forward time
Installing axe-core for simple a11y checksUse native toHaveAccessibleName/toHaveRole assertions
Using toPass() without explicit timeoutAlways pass { timeout: 10_000 } — default is 0 (forever)
Service worker silently blocking page.route()Set serviceWorkers: 'block' in context config when using MSW
Using fill() for autocomplete/debounce inputsUse pressSequentially() with optional delay for per-keystroke handling
storageState losing sessionStoragestorageState only saves cookies + localStorage — inject sessionStorage via addInitScript()

Delegation

  • Selector troubleshooting: Use Explore agent
  • Test pattern review: Use Task agent
  • Code review: Delegate to code-reviewer agent

For E2E test architecture, Page Object Model patterns, CI sharding strategies, authentication flows, visual regression workflows, or test organization, use the e2e-testing skill.

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

ui-ux-polish

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

tanstack-form

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

find-skills

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

tanstack-db

No summary provided by upstream source.

Repository SourceNeeds Review