Browser automation for visual testing, accessibility audits, and DOM inspection using Playwright. Use this skill when users need to: (1) Run accessibility (a11y) audits on websites and generate...
Browser automation toolkit for accessibility audits, screenshots, visual diffs, and DOM inspection.
Install dependencies before first use:
uv pip install playwright Pillow
playwright install chromium
Start Chrome with remote debugging:
# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
# Linux
google-chrome --remote-debugging-port=9222
# Windows
chrome.exe --remote-debugging-port=9222
Scripts then connect via --cdp-url http://localhost:9222.
Scripts launch a new browser and navigate to the specified URL. Use --headless for CI/automation.
Generate an a11y report for any website:
# Audit URL directly
uv run scripts/a11y_audit.py --url https://example.com
# Audit current page in connected browser
uv run scripts/a11y_audit.py --cdp-url http://localhost:9222
# Custom standards (wcag2a, wcag2aa, wcag21aa, best-practice)
uv run scripts/a11y_audit.py --url https://example.com --standards wcag21aa
Output: a11y-[domain].md with severity levels, affected elements, and remediation links.
# Basic screenshot
uv run scripts/screenshot.py --url https://example.com -o screenshot.png
# Full-page capture
uv run scripts/screenshot.py --url https://example.com --full-page -o full.png
# Screenshot specific element
uv run scripts/screenshot.py --url https://example.com --selector "#hero" -o hero.png
# Custom viewport
uv run scripts/screenshot.py --url https://example.com --width 375 --height 812 -o mobile.png
# From connected browser
uv run scripts/screenshot.py --cdp-url http://localhost:9222 -o current.png
Compare two screenshots to detect visual regressions:
# Basic diff (highlights changes in red)
uv run scripts/visual_diff.py --before baseline.png --after current.png -o diff.png
# Side-by-side comparison
uv run scripts/visual_diff.py --before a.png --after b.png --mode side-by-side -o compare.png
# Adjust sensitivity (lower = more sensitive)
uv run scripts/visual_diff.py --before a.png --after b.png --threshold 5 -o diff.png
# JSON output with metrics
uv run scripts/visual_diff.py --before a.png --after b.png --json
Interactively select elements to get DOM context:
# Pick from connected browser
uv run scripts/element_picker.py --cdp-url http://localhost:9222
# Pick from URL
uv run scripts/element_picker.py --url https://example.com
# Basic context only
uv run scripts/element_picker.py --cdp-url http://localhost:9222 --context basic
Returns JSON with:
Get information about the current page:
uv run scripts/browser.py info --cdp-url http://localhost:9222
When user asks "Is this website accessible?" or "Run an a11y audit":
a11y_audit.py with appropriate standardsWhen comparing before/after changes:
screenshot.py --url [url] -o baseline.pngscreenshot.py --url [url] -o current.pngvisual_diff.py --before baseline.png --after current.pngWhen user needs to modify specific elements:
element_picker.py to let user select element| Script | Purpose |
|---|---|
browser.py |
Core browser connection and page info |
a11y_audit.py |
Accessibility auditing with axe-core |
screenshot.py |
Screenshot capture (viewport, full-page, element) |
visual_diff.py |
Compare screenshots and generate diffs |
element_picker.py |
Interactive DOM element selection |
uv pip install playwright && playwright install chromium--remote-debugging-port=9222