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

55 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use doc, web-perf 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.
  • JetBrainsSkill

    doc

    Use when the task involves reading, creating, or editing `.docx` documents, especially when formatting or layout fidelity matters; prefer `python-docx` plus the bundled `scripts/render_docx.py` for visual checks.

    Also in 5 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 4 projects that use this

  • CloudflareSkill

    turnstile-spin

    Set up, repair, or migrate to Cloudflare Turnstile bot verification in an existing frontend and backend, including server-side Siteverify.

    Also in 3 projects that use this

  • CloudflareSkill

    cloudflare-one

    Design, configure, troubleshoot, or review Cloudflare One Zero Trust and SASE deployments. Use cloudflare-one-migrations for migration planning from other vendors.

    Also in 3 projects that use this

  • kayamanSkill

    edit-article

    Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.

    Also in 4 projects that use this

  • OpenAISkill

    durable-objects

    Create and review Cloudflare Durable Objects. Use when building stateful coordination (chat rooms, multiplayer games, booking systems), implementing RPC methods, SQLite storage, alarms, WebSockets, or reviewing DO code for best practices. Covers Workers integration, wrangler config, and testing with Vitest. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

    Also in 3 projects that use this

  • +2 more from openai

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 50 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 50 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.