web-ui-verification
Verify web UIs via headless Chrome CDP, no vision needed.
- License 许可
- MIT
- 最近更新
- 2026-08-16
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- web-ui-verification
- tags
- [ "web", "ui", "verification", "testing", "chrome", "cdp", "headless", "design-audit" ]
- author
- Hermes Agent
- license
- MIT
- version
- 1.0.0
- triggers
- [ "verify the page renders", "check the UI against a spec", "screenshot the site", "test button hover / modal / palette interactions", "check console errors", "computed style audit", "design system fidelity check" ]
- platforms
- [ "linux", "macos", "windows" ]
- description
- Verify web UIs via headless Chrome CDP, no vision needed.
02 资源文件 3
- 脚本scripts/ascii-region-view.py1.7 KB
- 脚本scripts/pixel-token-check.py3.3 KB
- 脚本templates/cdp-harness.mjs3.7 KB
03 SKILL.md 正文
Web UI Verification (headless Chrome via raw CDP)
Deterministic verification of web UIs when the normal browser tool can't reach the page
(file:// / localhost URLs blocked by the browser backend) or when browser_vision is
unavailable. No Playwright/puppeteer/npm needed — just a Chrome/Chromium binary and
Node's built-in WebSocket (Node >= 22 has global WebSocket).
When this fires
- The browser tool refuses private/localhost URLs. Serve the page with
python3 -m http.server <port> --bind 127.0.0.1, show it to the user viaopen_preview(localhost:<port>/...), and verify it yourself with this harness. - The vision provider is text-only (image analysis fails with
unknown variant image_url). The computed-style audit below is a stronger fidelity check than eyeballing anyway. - npm/Playwright install is network-blocked — raw CDP needs only the Chrome binary.
Faster path: puppeteer MCP browser (when available)
The mcp__puppeteer__* toolset runs its own headless Chrome and DOES reach localhost when
the main browser backend blocks it — a full interactive E2E + screenshots in minutes:
mcp__puppeteer__puppeteer_navigate { url, launchOptions: { headless: true,
args: ['--no-sandbox', '--disable-gpu'] },
allowDangerous: true }
mcp__puppeteer__puppeteer_fill { selector: '#email', value }
mcp__puppeteer__puppeteer_click { selector: 'button[type=submit]' }
mcp__puppeteer__puppeteer_screenshot { name, width: 1440, height: 900 }
Screenshots land in ~/.hermes/cache/images/img_*.png (share via MEDIA: path). Auth'd
flows work: fill → click → next navigate keeps the session cookie. Then verify pixels
(see below) — don't rely on the vision provider.
Pixel-level token verification (no vision)
Screenshot → color analysis with the bundled probe:
env -u PYTHONPATH python3 scripts/pixel-token-check.py <shot.png>
It reports canvas/card region averages, token pixel counts (gold-500 primary, silver
borders/text, semantic states), and an ASCII layout map — enough to prove design-system
compliance (Mavis or any token set, pass --tokens NAME=#RRGGBB for custom scales).
Tolerances: 18/channel exact tokens, ~24 for brand colors. Rich-content proof: high dark
text-pixel counts on table views = data rendered, not blank cards.
For zoomed region inspection ("is the subject visible in the hero band?"), use
scripts/ascii-region-view.py <shot.png> x0,y0,x1,y1 cols rows — renders any crop as an
ASCII luminance map so the composition (headline, subject mass, glow, road band) reads in
text.
Workflow
- Launch Chrome headless as a background process:
google-chrome --headless=new --disable-gpu --no-sandbox --disable-dev-shm-usage --remote-debugging-port=9333 --user-data-dir=/tmp/cdp-profile --window-size=1440,1000 about:blank - Poll
http://127.0.0.1:PORT/json/versionuntil it responds (CDP is up). - Open a tab:
PUT http://127.0.0.1:PORT/json/new?<encoded URL>→ returns{webSocketDebuggerUrl}. new WebSocket(webSocketDebuggerUrl); wire a pending-map (id → resolve) for responses and collectRuntime.consoleAPICalled+Runtime.exceptionThrownfor the zero-error report.Runtime.enable,Page.enable, sleep ~2.5s (plain pages) thenawait document.fonts.readybefore measuring. WebGL/Three.js pages need ~6s: headless Chrome's SwiftShader software rasterizer is slow to first paint — screenshots taken at 2–3.5s show blank/near-dark frames and produce false "scene is broken" alarms. On mobile emulation (setDeviceMetricsOverride+mobile:true) settle ~6.5s.- Run checks via
Runtime.evaluate(returnByValue:true, awaitPromise:true). - Screenshots via
Page.captureScreenshot(PNG base64). For full-page shots setEmulation.setDeviceMetricsOverridewidth/height todocument.documentElement.scrollHeight, then restore. - Real hover via
Input.dispatchMouseEvent{type:'mouseMoved', x, y}. - Kill Chrome when done.
Copy templates/cdp-harness.mjs — all of this is wired and ready to edit.
Pitfalls (learned the hard way)
- Synthetic key events: dispatching a KeyboardEvent on
document/windowcan miss document-level listeners. Dispatch ondocument.bodyor the focused element so it bubbles; for inputs set.valuefirst, then dispatchnew Event('input',{bubbles:true}). - Smooth scroll breaks mouse coordinates:
html{scroll-behavior:smooth}makesscrollIntoViewanimate — a freshly readgetBoundingClientRect()can be mid-flight. Usebehavior:'instant', then confirm the landing spot withdocument.elementFromPoint(x,y)before dispatching mouse events. :hoveris not queryable:querySelector('.btn:hover')is invalid. Check hover styles by moving the mouse for real and re-readinggetComputedStyle, or scandocument.styleSheetscssRules text for the hover rule.- Headless Chrome reports
prefers-color-scheme: darkeven for "light" designs, silently flipping dark-mode CSS. Add a?theme=deep-link override to the page (or emulate the scheme) and assert the active theme before any color assertions. - Full-page screenshots:
Page.captureScreenshotcaptures only the viewport — override device metrics to scrollHeight first. - Zero-error guarantee: subscribe to console/exception events before the page's scripts
run; report both in the final summary, not just
Runtime.evaluateresults. - Heredocs trip the command guard:
python3 - <<'EOF' … EOFvia the terminal tool can fail with "embedded null byte" (the lifecycle guard scans referenced scripts). Alwayswrite_filethe script to /tmp and execute the file instead — also true for signup / auth-flow / probe scripts. gl.readPixelsreturns zeros on Three.js pages:preserveDrawingBuffer:false(Three default) means the back buffer is consumed by compositing, so raw GL pixel probes read all-0 even when the scene renders fine. TrustPage.captureScreenshot(the composited truth) and pixel-stat the PNG instead of reading GL directly.- Blank-looking WebGL frames on the first screenshot: SwiftShader first paint lags ~5–6s (see step 5). Before concluding "canvas is empty", re-shoot after a longer settle — the earlier frame is a false alarm, not a scene bug.
- Mobile emulation:
Emulation.setDeviceMetricsOverridewithmobile:true+deviceScaleFactor:2— then assert thematchMediaquery fired, checkdocument.documentElement.scrollWidth - clientWidthfor overflow, and re-shoot each section; a viewport-only resize doesn't re-layout fixed/full-screen canvases.
Computed-style audit (design-fidelity verification)
When verifying against a design spec, assert instead of eyeball:
getComputedStyle(el).backgroundColor/color/fontSize/lineHeight/borderRadius/boxShadowcompared to spec tokens inrgb()form (e.g.#A87C2A→rgb(168, 124, 42)).- line-height math: computed px = unit × factor (16px × 1.55 = 24.8px).
- Overflow scan: elements with
scrollWidth > clientWidth + 2and overflow-x not auto/hidden/scroll — exclude intentional positioned children (e.g. tooltips viael.closest('.tip-wrap')). - Geometry: assert sidebar right ≤ main left (no overlap), fixed topbar overlapping the hero is intentional, etc.
- Element counts: expected swatches, type rows, buttons, icon cells.
- Tabular numbers:
fontVariantNumericincludestabular-nums.
Related
popular-web-designs— design templates; its "verify with browser_vision" step can be replaced by this skill's audit.dogfood— exploratory QA with interactive browser tools; complementary when those tools can reach the page and you want free-form bug hunting instead of scripted checks.
04 同仓库更多 Skills
test-driven-development
TDD: enforce RED-GREEN-REFACTOR, tests before code.
systematic-debugging
4-phase root cause debugging: understand bugs before fixing.
spike
Throwaway experiments to validate an idea before build.
simplify-code
Parallel 4-agent cleanup of recent code changes.
scroll-driven-3d-websites
Scroll-scrubbed 3D promo sites (Three.js + GSAP).
requesting-code-review
Pre-commit review: security scan, quality gates, auto-fix.