agentleFS
pencil20388-engpencil20388-eng/browser-automation-skills/skills/playwright/SKILL.md

playwright

Skill5 starsChanged 6 months agoMITView on GitHub

Automate browsers with Playwright — Microsoft's modern browser automation framework. Faster and more reliable than Selenium, with built-in auto-wait and network control.

  • Installs packages

94 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use develop-web-game, msw and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • hebertzhuSkill

    develop-web-game

    Use when building or iterating on a web game and you need a tight implement-test-observe loop; prefer the bundled Playwright client, inspect screenshots and text state, and validate every meaningful change before moving on.

    Also in 4 projects that use this

  • thongdn-itSkill

    msw

    MSW (Mock Service Worker) best practices for API mocking in tests (formerly test-msw). This skill should be used when setting up MSW, writing request handlers, or mocking HTTP APIs. This skill does NOT cover general testing patterns (use test-vitest or test-tdd skills) or test methodology.

    Also in 3 projects that use this

  • SupabaseSkill

    react-hook-form

    Correct React Hook Form usage anywhere in the monorepo — data flow, subscriptions,

    Also in 3 projects that use this

  • thongdn-itSkill

    tailwind

    Tailwind CSS v4 performance optimization and best practices guidelines (formerly tailwindcss-v4-style). This skill should be used when writing, reviewing, or refactoring Tailwind CSS v4 code to ensure optimal build performance, minimal CSS output, and correct usage of v4 features. Triggers on tasks involving Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.

    Also in 5 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 6 projects that use this

  • OpenAISkill

    web-perf

    Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (FCP, LCP, TBT, CLS, Speed Index), identifies render-blocking resources, network dependency chains, layout shifts, caching issues, and accessibility gaps. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed. Biases towards retrieval from current documentation over pre-trained knowledge.

    Also in 5 projects that use this

  • +1 more from thongdn-it

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 81 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use headless=False for debugging, headless=True (default) for production

    line 150

“Common” is measured: kept by at least 6 in 10 of the 81 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Playwright Browser Automation Skill

Automate browsers with Playwright — Microsoft's modern browser automation framework. Faster and more reliable than Selenium, with built-in auto-wait and network control.

Installation

pip install playwright
playwright install chromium  # or: playwright install  (all browsers)

Core Patterns

Open a page and navigate

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)  # headless=True for no UI
    page = browser.new_page()
    page.goto("https://example.com")
    print(page.title())
    browser.close()

Async version

import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto("https://example.com")
        print(await page.title())
        await browser.close()

asyncio.run(main())

Click, fill, select

page.click("button.submit")                        # Click a button
page.fill("#username", "my_user")                   # Fill an input
page.fill("#password", "my_pass")
page.select_option("select#country", "US")          # Select dropdown
page.check("input#agree")                           # Check a checkbox
page.press("#search", "Enter")                      # Press a key

Wait for elements

page.wait_for_selector(".results", timeout=10000)   # Wait up to 10s
page.wait_for_load_state("networkidle")              # Wait for network quiet
page.wait_for_url("**/dashboard")                    # Wait for navigation

Extract data

text = page.text_content("h1")                      # Single element text
href = page.get_attribute("a.link", "href")          # Attribute value
items = page.query_selector_all(".product")          # Multiple elements
for item in items:
    name = item.text_content()
    price = item.query_selector(".price").text_content()

Screenshots

page.screenshot(path="page.png")                     # Viewport screenshot
page.screenshot(path="full.png", full_page=True)     # Full page
element = page.query_selector(".chart")
element.screenshot(path="chart.png")                 # Element only

PDF generation

page.pdf(path="report.pdf", format="A4", print_background=True)

Network interception

# Block images to speed up loading
def handle_route(route):
    if route.request.resource_type == "image":
        route.abort()
    else:
        route.continue_()

page.route("**/*", handle_route)
page.goto("https://example.com")

# Intercept and modify a request
def modify_request(route):
    headers = {**route.request.headers, "X-Custom": "value"}
    route.continue_(headers=headers)

page.route("**/api/**", modify_request)

Multiple browser contexts (isolated sessions)

context1 = browser.new_context()
context2 = browser.new_context()
page1 = context1.new_page()  # Separate cookies, storage
page2 = context2.new_page()  # Completely isolated

Set viewport and emulate devices

page.set_viewport_size({"width": 1920, "height": 1080})

# Or emulate a device
iphone = p.devices["iPhone 13"]
context = browser.new_context(**iphone)

Multi-browser support

browser = p.chromium.launch()    # Chrome/Edge
browser = p.firefox.launch()     # Firefox
browser = p.webkit.launch()      # Safari

Common errors

ErrorFix
"Browser not installed"Run playwright install chromium
"Timeout waiting for selector"Increase timeout or check selector
"Navigation failed"Page might require JavaScript; use wait_for_load_state
"Element not visible"Use force=True or wait for visibility

Important notes

  • Playwright auto-waits for elements before interacting — usually no need for time.sleep()
  • Use headless=False for debugging, headless=True (default) for production
  • Each browser.new_context() creates an isolated session (separate cookies, localStorage)
  • page.goto() waits for load event by default; use wait_until="networkidle" for SPAs

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.