mcpField
W
web-automation

web-automation

github.com/mauromeddaTesting & quality1361 installsUpdated 41w ago
Repository

About web-automation

web-automation is a Claude Code skill for browser automation and debugging with Playwright in Python or JavaScript/TypeScript. It supports interactive tasks, passive monitoring, and E2E testing, with scripts for screenshots, network traffic, console errors, and visual comparison.

Key features

  1. 01Browser interaction with Playwright
  2. 02Network and console monitoring
  3. 03Screenshot capture and visual comparison
  4. 04E2E testing guidance
  5. 05Python and JavaScript/TypeScript examples

Use cases

  1. 01Automating login and form submissions
  2. 02Checking UI fixes and visual changes
  3. 03Reproducing browser bugs
  4. 04Reviewing network and console output for security issues

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mauromedda/agent-toolkit --skill web-automation

After installing, type/web-automationin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

examples/js/
console_logging.js
element_discovery.js
screenshot_capture.js
examples/python/
console_logging.py
element_discovery.py
form_interaction.py
screenshot_capture.py
visual_compare.py
references/
javascript-patterns.md
python-patterns.md
test-framework.md
scripts/
cdp_session.py
combined_debugger.py
console_debugger.py
cookie_consent.py
network_inspector.py
server_utils.py
test_utils.py

Details

From the project README

ABOUTME: Claude Code skill for web automation, debugging, and E2E testing using Playwright

ABOUTME: Covers interactive automation, passive monitoring, screenshots, and security verification

Web Automation with Playwright

Browser automation and debugging using Playwright in Python or JavaScript/TypeScript.

Detailed patterns: See references/python-patterns.md and references/javascript-patterns.md


Quick Reference

TaskHelper Script
Login / fill formsexamples/python/form_interaction.py
Take screenshotsexamples/python/screenshot_capture.py
Handle cookie consentscripts/cookie_consent.py
Discover page elementsexamples/python/element_discovery.py
Capture network trafficscripts/network_inspector.py
Debug console errorsscripts/console_debugger.py
Full debug (network+console)scripts/combined_debugger.py
Compare websites visuallyexamples/python/visual_compare.py

Always run helpers first:

uv run ~/.claude/skills/web-automation/examples/python/element_discovery.py http://localhost:3000
uv run ~/.claude/skills/web-automation/examples/python/screenshot_capture.py http://localhost:3000 --output /tmp/shots

Modes of Operation

ModeWhen to UseExample
InteractiveClick, type, navigateLogin flow, form submission
PassiveObserve onlyNetwork capture, console monitoring
E2E TestingAutomated test suitesPlaywright Test framework

When to Invoke (Proactive)

  1. Verifying UI fixes - After changing frontend code
  2. Testing form fields/dropdowns - Verify correct values display
  3. Confirming visual changes - Take screenshots
  4. Reproducing bugs - Automate steps to reproduce
  5. Security verification - After Gemini/static analysis finds issues

🔄 RESUMED SESSION CHECKPOINT

┌─────────────────────────────────────────────────────────────┐
│  SESSION RESUMED - WEB AUTOMATION VERIFICATION              │
│                                                             │
│  1. Was I in the middle of browser automation?              │
│     → Run: ps aux | grep -E "chromium|playwright|node"      │
│                                                             │
│  2. Were there UI verification tasks pending?               │
│     → Check summary for "verify", "test UI", "screenshot"   │
│                                                             │
│  3. Did previous automation capture any findings?           │
│     → Check /tmp/ for screenshots, debug outputs            │
└─────────────────────────────────────────────────────────────┘

Decision Flow

Task:
    +-- Need to interact? (click, type, submit) → Interactive mode
    +-- Just observe/capture? → Passive mode (combined_debugger.py)
    +-- Security verification? → Passive mode + grep for sensitive patterns

CRITICAL: Handling Overlays

Overlays WILL block automation. Always dismiss after page.goto():

Python (Quick Pattern)
page.goto('https://example.com')
page.wait_for_load_state('networkidle')

# Dismiss cookie consent
for sel in ['button:has-text("Accept all")', '[class*="cookie"] button[class*="accept"]']:
    try:
        btn = page.locator(sel).first
        if btn.is_visible(timeout=2000):
            btn.click()
            break
    except:
        continue
Nuclear Option (Remove All Overlays)
page.evaluate('''() => {
    const patterns = ['cookie', 'consent', 'modal', 'overlay', 'popup', 'backdrop'];
    for (const p of patterns) {
        document.querySelectorAll(`[class*="${p}"], [id*="${p}"]`).forEach(el => {
            if (getComputedStyle(el).position === 'fixed') el.remove();
        });
    }
    document.body.style.overflow = 'auto';
}''')

Full implementation: See references/python-patterns.md


Core Patterns

Python
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    page = browser.new_page()
    page.goto('http://localhost:3000')
    page.wait_for_load_state('networkidle')  # CRITICAL
    # ... automation
    browser.close()
JavaScript
import { test, expect } from '@playwright/test';

test('example', async ({ page }) => {
  await page.goto('/');
  await page.waitForLoadState('networkidle');
  await expect(page.locator('.element')).toBeVisible();
});

Common Operations

OperationPythonJavaScript
Screenshotpage.screenshot(path='/tmp/s.png')await page.screenshot({ path: '/tmp/s.png' })
Full pagepage.screenshot(path='/tmp/s.png', full_page=True)await page.screenshot({ path: '/tmp/s.png', fullPage: true })
Fill inputpage.fill('input[name="email"]', '[email protected]')await page.fill('input[name="email"]', '[email protected]')
Select dropdownpage.select_option('select#id', 'value')await page.selectOption('select#id', 'value')
Clickpage.click('button[type="submit"]')await page.click('button[type="submit"]')
Wait networkpage.wait_for_load_state('networkidle')await page.waitForLoadState('networkidle')
Wait elementpage.wait_for_selector('.result')await page.waitForSelector('.result')

Selector Strategies (Order of Preference)

  1. Role-based: page.get_by_role('button', name='Submit')
  2. Text-based: page.get_by_text('Click me')
  3. Test IDs: page.get_by_test_id('submit-btn')
  4. CSS: page.locator('.btn-primary')
  5. XPath (last resort): page.locator('//button[@type="submit"]')

Verification Checklist

What to VerifyApproach
Dropdown valuepage.locator('select').input_value()
Input textpage.locator('input').input_value()
Element visiblepage.locator('.element').is_visible()
Text contentpage.locator('.element').text_content()
Page URLpage.url after action

Passive Debugging Scripts

ScriptPurposeExample
combined_debugger.pyNetwork + Console + Errorsuv run ... --duration 30 --output /tmp/debug.json
network_inspector.pyNetwork onlyuv run ... --errors-only
console_debugger.pyConsole/errors onlyuv run ... --with-stack-traces
Security Verification
# After Gemini found sensitive data logging
uv run ~/.claude/skills/web-automation/scripts/console_debugger.py \
    http://localhost:3000 --duration 60 --output /tmp/security.json

grep -i "password\|token\|secret\|bearer" /tmp/security.json

Visual Comparison

NEVER say "I cannot visually browse". Instead:

# Compare two sites
uv run ~/.claude/skills/web-automation/examples/python/visual_compare.py \
    https://reference-site.com \
    http://localhost:3000 \
    --output /tmp/compare

# Then read the screenshots using Read tool

Language Selection

Use CaseRecommendedReason
Existing JS/TS projectJavaScriptConsistent tooling
Existing Python projectPythonConsistent tooling
Quick scriptsPythonSimpler setup with uv run
Test suitesJavaScriptBetter @playwright/test framework

Test Framework Integration

See references/test-framework.md for:

  • Unified test runner (test_utils.py)
  • Server auto-detection and startup
  • Framework detection (Playwright, Jest, pytest, etc.)
# Detect and run tests with server
uv run ~/.claude/skills/web-automation/scripts/test_utils.py . --run --with-server

Common Pitfalls

PitfallSolution
Overlay blocking clicksCall overlay dismissal after EVERY page load
DOM inspection before JS loadsAlways wait_for_load_state('networkidle') first
Headful browser in CIAlways use headless: true
Flaky selectorsPrefer role/text selectors over CSS classes
Race conditionsUse explicit waits, not wait_for_timeout

Prerequisites

Python

Scripts include inline dependencies (PEP 723); uv run auto-installs them.

JavaScript
npm init -y
npm install -D @playwright/test
npx playwright install chromium

Running E2E Tests

JavaScript
npx playwright test                    # Run all
npx playwright test --ui               # UI mode
npx playwright test --headed           # See browser
Python
pip install pytest-playwright
pytest tests/

Comments

Markdown supported