Probe My Page
Read the numbers from the page; do not drive the pointer. Dragging, hovering
and screenshot-eyeballing are slow, flaky and cannot tell a 2px or 100ms
difference. The DOM already knows: getBoundingClientRect, getComputedStyle,
element.getAnimations(), performance.now(), el.click(),
dispatchEvent. A script injected into the page (or run through
page.evaluate in Playwright, or the browser tool's JavaScript action) returns
exact values in one call.
The method (do it in this order)
- Baseline BEFORE you change anything. Once the old implementation is gone you cannot measure it. If the change is reversible (migration with rollback, git stash, feature flag) you can restore it later to re-baseline; say so in your plan. Save baselines to files.
- Write one adapter per implementation (old and new have different class
names). An adapter is just a selector map:
root,item,active,content,title,button,dot,arrowNext,img, ... The measured values are semantic (position inside the component, font size, colour, count, duration) so old and new can be compared even though the DOM differs. - Pick the matrix: viewports (default 1440, 1024, 768, 390), languages,
and states (every slide / tab / accordion item / open-closed). Measure each
state by triggering it from script (
el.click()), waiting for it to settle, then snapshotting. Never rely on "whatever is active at load" (autoplay moves it). - Measure three kinds of facts (see
scripts/probe.js):- static: rect relative to the component root, computed font/colour/padding/
opacity, counts,
object-fit, display, z-order; - motion: computed
transition-*/animation-*of the parts, plusgetAnimations(); read the declared timing instead of sampling frames; - behaviour: autoplay interval (timestamps of active-index changes), pause on
hover (dispatch
mouseover/mouseenter, nothing changes for N seconds), keyboard (dispatchkeydown), network weight (performance.getEntriesByType('resource')).
- static: rect relative to the component root, computed font/colour/padding/
opacity, counts,
- Save, don't print. Post results to a tiny local server (
scripts/srv.py) so large JSON never enters the conversation; print only a one-line summary. - Diff with a tolerance (
scripts/compare.py, 1px by default, aliases such asstart=left). Report only differing values, grouped by state and viewport, plus what matched. Explain each difference: bug, deliberate choice, or measuring artefact; then fix CSS/markup and re-measure the same matrix. - State what you did not measure (hover-only CSS, real touch, other browsers, frame-exact easing, production data).
Setup (the pieces)
python3 scripts/srv.py # serves probe.js and stores POSTed results in ./results/
In the page (browser tool JS action, Playwright page.addScriptTag, or devtools):
await new Promise((res, rej) => { const s = document.createElement('script');
s.src = 'http://127.0.0.1:8777/probe.js?' + Date.now(); s.onload = res; s.onerror = rej; document.head.appendChild(s); });
__P.adapters.old = { root: '.old-slider', item: '.old-slide', active: '.is-active', dot: '.old-dots button', /* ... */ };
await __P.save('old_1440_static', await __P.snapshot('old'));
Use an HTTP page when the server is HTTP (mixed content blocks http:// scripts on HTTPS pages).
Resize the viewport through the tool (resize_window / page.setViewportSize),
reload, wait for load, then measure.
Rules that save hours
- Prefer declared values to sampled frames: a transition's duration, delay
and easing come from
getComputedStyle; samplingrequestAnimationFrameonly proves it ran. - Hidden or background panes do not render frames: CSS transitions stay at
their start value until a frame is produced, so computed styles lag.
Call
await __P.settle()(several rAF + short sleeps) before every measurement and set an explicit viewport. Details:references/gotchas.md. - Pause autoplay before measuring (
__P.hover(el, true)), or measure it on purpose with__P.watch. - Pseudo-classes (
:hover,:focus,:active) cannot be set from script. Read the stylesheet rules for them (references/gotchas.md) or test one real hover with the tool; do not build the whole check on it. - Compare the same slide/state on both sides; a different active slide looks like a layout bug.
- A one-off difference of a few px at one viewport is usually content height or rounding: check the neighbours before "fixing".
- Keep measuring tools with the project (
docs/measurements/<date>-<topic>/) together with the raw results, so the check is repeatable on stage/live. - When a result surprises you, inspect the DOM before theorising: list the matching CSS rules for the property, the element's classes, the data it was built from.
Output to the user
A short table: what was compared, matrix, number of differing values, the differences with cause (bug / intentional / artefact), what was fixed, what is not covered. Offer the raw results path.
Files
scripts/probe.jsgeneric harness:snapshot,motion,watch,hover,settle,perItem,resources,save.scripts/srv.pystatic server +POST /save?name=...with CORS.scripts/compare.pyflat diff of two result files with tolerance and aliases.references/gotchas.mdrendering pitfalls and how to read CSS rules and animations.