Skip to content

t1k:web:testing:chrome-devtools

FieldValue
Moduletesting
Version1.7.0
Efforthigh
Tools

Keywords: browser, devtools, puppeteer, scraping, screenshots, testing

/t1k:web:testing:chrome-devtools
[url or task]

Browser automation via Puppeteer scripts with persistent sessions. All scripts output JSON.

Skills can exist in project-scope or user-scope. Priority: project-scope > user-scope.

Terminal window
# Detect skill location (no cd needed - scripts use __dirname for paths)
SKILL_DIR=""
if [ -d ".claude/skills/chrome-devtools/scripts" ]; then
SKILL_DIR=".claude/skills/chrome-devtools/scripts"
elif [ -d "$HOME/.claude/skills/chrome-devtools/scripts" ]; then
SKILL_DIR="$HOME/.claude/skills/chrome-devtools/scripts"
fi
# Run scripts with full path: node "$SKILL_DIR/script.js" --args
ScenarioApproach
Source-available sitesRead source code first, write selectors directly
Unknown layoutsUse aria-snapshot.js for semantic discovery
Visual inspectionTake screenshots to verify rendering
Debug issuesCollect console logs, analyze with session storage
Accessibility auditUse ARIA snapshot for semantic structure analysis

Browser visibility is resolved automatically by resolveHeadless() in lib/browser.js:

EnvironmentDefaultWhy
macOS / WindowsHeaded (visible)Better debugging, OAuth login support
Linux / WSLHeadlessServers typically have no display
CI (CI, GITHUB_ACTIONS, GITLAB_CI, JENKINS_URL env vars)HeadlessNo display available

Override with --headless true or --headless false on any script.

  • Run multiple scripts/sessions in parallel to simulate real user interactions.
  • Run multiple scripts/sessions in parallel to simulate different device types (mobile, tablet, desktop).

Full ARIA snapshot guide: see references/aria-snapshot-guide.md.

IMPORTANT: Never browse local HTML files via file:// protocol. Always serve via local server: Why: file:// protocol blocks many browser features (CORS, ES modules, fetch API, service workers). Local server ensures proper HTTP behavior.

Terminal window
# Option 1: npx serve (recommended)
npx serve ./dist -p 3000 &
node "$SKILL_DIR/navigate.js" --url http://localhost:3000
# Option 2: Python http.server
python -m http.server 3000 --directory ./dist &
node "$SKILL_DIR/navigate.js" --url http://localhost:3000

Note: when port 3000 is busy, find an available port with lsof -i :3000 and use a different one.

Terminal window
# Install dependencies (one-time setup)
npm install --prefix "$SKILL_DIR"
# Test (browser stays running for session reuse)
node "$SKILL_DIR/navigate.js" --url https://example.com
# Output: {"success": true, "url": "...", "title": "..."}

Linux/WSL only: Run "$SKILL_DIR/install-deps.sh" first for Chrome system libraries.

Browser state persists across script executions via WebSocket endpoint file (.browser-session.json).

Default behavior: Scripts disconnect but keep browser running for session reuse.

Terminal window
# First script: launches browser, navigates, disconnects (browser stays running)
node "$SKILL_DIR/navigate.js" --url https://example.com/login
# Subsequent scripts: connect to existing browser, reuse page state
node "$SKILL_DIR/fill.js" --selector "#email" --value "[email protected]"
node "$SKILL_DIR/fill.js" --selector "#password" --value "secret"
node "$SKILL_DIR/click.js" --selector "button[type=submit]"
# Close browser when done
node "$SKILL_DIR/navigate.js" --url about:blank --close true

All in .claude/skills/chrome-devtools/scripts/:

ScriptPurpose
navigate.jsNavigate to URLs
screenshot.jsCapture screenshots (auto-compress >5MB via Sharp)
click.jsClick elements
fill.jsFill form fields
evaluate.jsExecute JS in page context
snapshot.jsExtract interactive elements (JSON format)
aria-snapshot.jsGet ARIA accessibility tree (YAML format with refs)
select-ref.jsInteract with elements by ref from ARIA snapshot
console.jsMonitor console messages/errors
network.jsTrack HTTP requests/responses
performance.jsMeasure Core Web Vitals
ws-debug.jsDebug WebSocket connections (basic)
ws-full-debug.jsDebug WebSocket with full events/frames
inject-auth.jsInject cookies/tokens for authentication
import-cookies.jsImport cookies from JSON/Netscape file
connect-chrome.jsConnect to Chrome with remote debugging
  1. Execute focused script for single task
  2. Observe JSON output
  3. Assess completion status
  4. Decide next action
  5. Repeat until done

Full screenshots, console log, and patterns reference: see references/script-command-reference.md.

Terminal window
# Inject single cookie
node "$SKILL_DIR/inject-auth.js" --url https://site.com \
--cookies '[{"name":"session","value":"abc123","domain":".site.com"}]'
Terminal window
# Open browser at login page, wait for redirect to dashboard after OAuth
node "$SKILL_DIR/navigate.js" --url https://app.example.com/login \
--wait-for-login "/dashboard"

If script fails:

Terminal window
# 1. Capture current state
node "$SKILL_DIR/screenshot.js" --output ./.claude/skills/chrome-devtools/screenshots/debug.png
# 2. Get console errors
node "$SKILL_DIR/console.js" --url about:blank --types error --duration 1000
# 3. Discover correct selector
node "$SKILL_DIR/snapshot.js" | jq '.elements[] | select(.text | contains("Submit"))'
ErrorSolution
Cannot find package 'puppeteer'Run npm install in scripts directory
libnss3.so missing (Linux)Run ./install-deps.sh
Element not foundUse snapshot.js to find correct selector
Script hangsUse --timeout 60000 or --wait-until load
Screenshot >5MBAuto-compressed; use --max-size 3 for lower
Session staleDelete .browser-session.json and retry
  • ./references/cdp-domains.md - Chrome DevTools Protocol domains
  • ./references/puppeteer-reference.md - Puppeteer API patterns
  • ./references/performance-guide.md - Core Web Vitals optimization
  • Performance recordings reset on tab refresh — capture-then-export, don’t trust live recordings to survive nav.
  • Coverage reports include every file traversed, NOT every file used at runtime — interpret carefully.
  • Source maps must be uploaded BEFORE first error report — Sentry-style integrations otherwise fingerprint minified stacks.