playwright-skill
Browser automation for web tasks. Use when the user needs to automate browser interactions, take screenshots, extract data from websites, fill forms, or perform web scraping. Supports persistent sessions for logged-in state.
What this skill does
# Playwright Skill - Browser Automation Automate browser tasks: navigate, click, type, extract data, take screenshots, and more. ## First-Time Setup ```bash pip install playwright playwright install chromium ``` ## Core Concepts ### Sessions Sessions persist browser state (cookies, localStorage) across commands. Use named sessions for different accounts/sites: ```bash # Default session python3 ~/.claude/skills/playwright-skill/playwright_skill.py open https://example.com # Named session for a specific site python3 ~/.claude/skills/playwright-skill/playwright_skill.py open https://github.com --session github ``` Sessions are saved to `~/.claude/skills/playwright-skill/sessions/` ### Headless vs Visible By default, browser runs headless (invisible). Use `--visible` to see what's happening: ```bash python3 ~/.claude/skills/playwright-skill/playwright_skill.py open https://example.com --visible ``` ## Commands ### Navigation ```bash # Open a URL python3 ~/.claude/skills/playwright-skill/playwright_skill.py open URL [--session NAME] [--visible] # Wait for element to appear python3 ~/.claude/skills/playwright-skill/playwright_skill.py wait SELECTOR [--timeout MS] [--session NAME] # Scroll page python3 ~/.claude/skills/playwright-skill/playwright_skill.py scroll [--direction up|down] [--amount PIXELS] [--session NAME] ``` ### Interaction ```bash # Click an element python3 ~/.claude/skills/playwright-skill/playwright_skill.py click SELECTOR [--session NAME] # Type text into input python3 ~/.claude/skills/playwright-skill/playwright_skill.py type SELECTOR "text to type" [--clear] [--session NAME] # Execute JavaScript python3 ~/.claude/skills/playwright-skill/playwright_skill.py eval "document.title" [--session NAME] ``` ### Data Extraction ```bash # Extract text from element python3 ~/.claude/skills/playwright-skill/playwright_skill.py extract SELECTOR [--session NAME] # Extract attribute python3 ~/.claude/skills/playwright-skill/playwright_skill.py extract "a.link" --attr href [--session NAME] # Extract from all matching elements python3 ~/.claude/skills/playwright-skill/playwright_skill.py extract "li.item" --all [--session NAME] # Get page HTML python3 ~/.claude/skills/playwright-skill/playwright_skill.py html [--selector SELECTOR] [--output FILE] [--session NAME] ``` ### Screenshots & PDF ```bash # Screenshot current page python3 ~/.claude/skills/playwright-skill/playwright_skill.py screenshot [--output FILE] [--session NAME] # Screenshot with URL python3 ~/.claude/skills/playwright-skill/playwright_skill.py screenshot https://example.com --output example.png # Full-page screenshot python3 ~/.claude/skills/playwright-skill/playwright_skill.py screenshot --full-page --output full.png # Save as PDF python3 ~/.claude/skills/playwright-skill/playwright_skill.py pdf https://example.com --output page.pdf ``` ### Cookies & Sessions ```bash # List all cookies python3 ~/.claude/skills/playwright-skill/playwright_skill.py cookies [--session NAME] # Get specific cookie python3 ~/.claude/skills/playwright-skill/playwright_skill.py cookies --name session_id [--session NAME] # Set cookie python3 ~/.claude/skills/playwright-skill/playwright_skill.py cookies --set "name=value" --domain example.com [--session NAME] # List all sessions python3 ~/.claude/skills/playwright-skill/playwright_skill.py sessions # Close session (saves state) python3 ~/.claude/skills/playwright-skill/playwright_skill.py close [--session NAME] # Close all sessions python3 ~/.claude/skills/playwright-skill/playwright_skill.py close --all ``` ## Selectors Playwright supports multiple selector types: ```bash # CSS selectors python3 ~/.claude/skills/playwright-skill/playwright_skill.py click "button.submit" python3 ~/.claude/skills/playwright-skill/playwright_skill.py click "#login-form input[type=email]" # Text selectors python3 ~/.claude/skills/playwright-skill/playwright_skill.py click "text=Sign In" python3 ~/.claude/skills/playwright-skill/playwright_skill.py click "text=Submit" # XPath python3 ~/.claude/skills/playwright-skill/playwright_skill.py click "xpath=//button[@type='submit']" # Combining python3 ~/.claude/skills/playwright-skill/playwright_skill.py click "form >> text=Submit" ``` ## Examples ### Login Flow (Manual First Time) ```bash # Open login page visibly python3 ~/.claude/skills/playwright-skill/playwright_skill.py open https://example.com/login --visible --session mysite # ... manually log in while browser is visible ... # Close to save session python3 ~/.claude/skills/playwright-skill/playwright_skill.py close --session mysite # Future runs use saved session (logged in) python3 ~/.claude/skills/playwright-skill/playwright_skill.py open https://example.com/dashboard --session mysite ``` ### Scrape a List ```bash # Open page python3 ~/.claude/skills/playwright-skill/playwright_skill.py open https://news.ycombinator.com # Extract all headlines python3 ~/.claude/skills/playwright-skill/playwright_skill.py extract ".titleline a" --all # Extract with links python3 ~/.claude/skills/playwright-skill/playwright_skill.py extract ".titleline a" --attr href --all ``` ### Fill a Form ```bash python3 ~/.claude/skills/playwright-skill/playwright_skill.py open https://example.com/form --session formtest python3 ~/.claude/skills/playwright-skill/playwright_skill.py type "input[name=email]" "[email protected]" --session formtest python3 ~/.claude/skills/playwright-skill/playwright_skill.py type "input[name=message]" "Hello world" --session formtest python3 ~/.claude/skills/playwright-skill/playwright_skill.py click "button[type=submit]" --session formtest ``` ### Screenshot a Page ```bash python3 ~/.claude/skills/playwright-skill/playwright_skill.py screenshot https://example.com --output example.png --full-page ``` ### Run JavaScript ```bash # Get page title python3 ~/.claude/skills/playwright-skill/playwright_skill.py eval "document.title" # Get scroll position python3 ~/.claude/skills/playwright-skill/playwright_skill.py eval "window.scrollY" # Count elements python3 ~/.claude/skills/playwright-skill/playwright_skill.py eval "document.querySelectorAll('a').length" ``` ## Output All commands output JSON for easy parsing. ## Requirements - Python 3.9+ - `pip install playwright` - `playwright install chromium` ## Tips - **First login**: Use `--visible` to manually log in, then save session for headless reuse - **Flaky selectors**: Use `wait` command before interacting with dynamic content - **Rate limiting**: Add delays between actions with `eval "await new Promise(r => setTimeout(r, 2000))"` - **Debugging**: Take screenshots to see what went wrong - **Multiple accounts**: Use different session names for each account ## Security Notes - Session files contain authentication cookies - keep `sessions/` directory secure - Don't share session files - they can grant account access - Clear sessions when done with sensitive sites: `close --session NAME`
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.