Install
openclaw skills install visual-qaPerform pixel-level visual regression testing on web apps by capturing, comparing screenshots, and gating deployments based on configurable similarity thresh...
openclaw skills install visual-qaA visual regression testing pipeline for web applications. Capture baseline screenshots of your app, compare new screenshots against baselines using pixel-level diffing, and pass/fail based on configurable similarity thresholds.
# Capture single URL
python scripts/capture.py http://localhost:3000 --output .visual-qa/baselines
# Capture multiple viewports
python scripts/capture.py http://localhost:3000 --viewports desktop mobile tablet --output .visual-qa/baselines
# Capture multiple pages from config
python scripts/capture.py --config .visual-qa.json --output .visual-qa/baselines
# Compare new screenshots
python scripts/diff.py --baseline .visual-qa/baselines --current .visual-qa/current --threshold 99
# Capture + diff in one command
python scripts/gate.py --baseline .visual-qa/baselines --url http://localhost:3000 --threshold 99
# With local dev server
python scripts/gate.py --baseline .visual-qa/baselines --server "npm run dev" --port 3000 --threshold 99
# Using config file
python scripts/gate.py --config .visual-qa.json
Create .visual-qa.json in your project root:
{
"urls": ["/", "/about", "/pricing"],
"baseUrl": "http://localhost:3000",
"viewports": ["desktop", "mobile"],
"threshold": 99,
"server": "npm run dev",
"port": 3000,
"baselineDir": ".visual-qa/baselines",
"ignore": [".visual-qa/diffs", ".visual-qa/current"]
}
All scripts support --help for detailed usage.
Capture screenshots using Playwright (headless Chromium).
Features:
{url-slug}_{viewport}.pngUsage:
python scripts/capture.py <url> --output <dir> [options]
python scripts/capture.py --config <config.json> --output <dir>
Compare screenshots using pixel-level diffing (Pillow).
Features:
Usage:
python scripts/diff.py --baseline <dir> --current <dir> --output <diff-dir> --threshold <percent>
All-in-one gate: capture + diff in a single command.
Features:
Usage:
python scripts/gate.py --baseline <dir> --url <url> --threshold <percent>
python scripts/gate.py --baseline <dir> --server <command> --port <port> --threshold <percent>
python scripts/gate.py --config <config.json>
# Start your app
npm run dev
# Capture baselines (desktop + mobile)
python scripts/capture.py http://localhost:3000 --viewports desktop mobile --output .visual-qa/baselines
# In your CI pipeline after build
python scripts/gate.py --baseline .visual-qa/baselines --server "npm start" --port 3000 --threshold 99
# Exit code 0 = pass, 1 = fail
if [ $? -eq 0 ]; then
echo "Visual QA passed ✓"
else
echo "Visual QA failed ✗"
exit 1
fi
# 1. Developer makes UI changes
# 2. Capture new screenshots
python scripts/capture.py http://localhost:3000 --output .visual-qa/current
# 3. Generate diff images
python scripts/diff.py --baseline .visual-qa/baselines --current .visual-qa/current --output .visual-qa/diffs
# 4. Review diff images in .visual-qa/diffs/
# 5. If changes are intentional, update baselines:
rm -rf .visual-qa/baselines
mv .visual-qa/current .visual-qa/baselines
Create .visual-qa.json:
{
"urls": ["/", "/products", "/about", "/contact"],
"baseUrl": "http://localhost:3000",
"viewports": ["desktop", "mobile"],
"threshold": 99,
"baselineDir": ".visual-qa/baselines"
}
# Capture all pages
python scripts/capture.py --config .visual-qa.json --output .visual-qa/baselines
# Gate all pages
python scripts/gate.py --config .visual-qa.json
Scripts require Playwright and Pillow:
pip install playwright pillow
python -m playwright install chromium
Scripts will check for dependencies and print install instructions if missing.
The --threshold parameter controls similarity percentage (0-100):
Experiment to find the right threshold for your app. Start strict (99%) and loosen if you get false positives.
For pages with dynamic content (dates, user-specific data):
Use data attributes to hide dynamic elements during testing:
[data-test-hide] { visibility: hidden !important; }
Capture specific viewport regions (future enhancement)
Loosen threshold for pages with acceptable dynamic content
"Command not found: python"
python3 instead of python"Playwright not installed"
pip install playwright && python -m playwright install chromium"Similarity below threshold but images look the same"
"Server not starting"
--port matches your server's portnpm run dev, npm start, etc.)"Images not found"
{url-slug}_{viewport}.png.visual-qa/diffs and .visual-qa/current to .gitignoreFor detailed script options, run:
python scripts/capture.py --help
python scripts/diff.py --help
python scripts/gate.py --help