Skip to content

Add element snapshots - #43

Merged
brynary merged 3 commits into
snapshot-comparison-optionsfrom
element-snapshots
Oct 5, 2026
Merged

brynary merged 3 commits into
snapshot-comparison-optionsfrom
element-snapshots

Conversation

@brynary

@brynary brynary commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Stacked on #34. This branch was pushed earlier as the base of #35 without a PR of its own; this PR makes it reviewable.

SNAPSHOT name locator compares one element instead of the full page, as in SNAPSHOT cart testid:cart.

  • The locator follows the name and takes prefixed segments only, like an ACT scope. It must match exactly one element, and Whirl resolves it again for every capture, scrolls it into view, and crops the image to it. Chains, nth:, and frames work.
  • Masks still resolve from the whole page, and a snapshot-max-diff percentage counts the element's pixels.
  • Playwright 1.62.1 resolves the element once per locator.screenshot() and throws when the page replaces it, so the shim retries detached, zero-size, and not-visible captures within the step timeout.
  • After a stable mismatch, a capture that times out checks the target once without waiting: a missing or hidden target fails as a timeout instead of a mismatch on old pixels.
  • The snapshot command carries a required target, so the shim protocol moves to 4. JSON and HTML reports record the target. Baseline paths do not change, so run --update-snapshots after adding or removing a locator.

The last commit fixes a test that failed on every CI runner in this stack (#35–#42): the test page replaced the snapshot target every 30 ms forever, so on the slower runners a capture never found a steady element within the step's 3 s. The page now stops after the first second and the step gets 5 s; early captures still have to find the replaced target again.

Validation: mise run check.

🤖 Generated with Claude Code

brynary and others added 3 commits October 5, 2026 10:02
SNAPSHOT name locator compares one element instead of the full page,
as in SNAPSHOT cart testid:cart. The locator follows the name and takes
prefixed segments only, like an ACT scope. It must match exactly one
element and resolves again for every capture. Masks still resolve from
the page, and percentages count the element's pixels.

Playwright 1.62.1 resolves the element once per locator.screenshot()
and throws when the page replaces it, so the shim retries detached,
zero-size, and not-visible captures within the step timeout. After a
stable mismatch, a capture that times out checks the target once
without waiting: a missing or hidden target fails as a timeout instead
of a mismatch on old pixels.

The snapshot command carries a required target, so the shim protocol
moves to 4. JSON and HTML reports record the target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test page replaced the snapshot target every 30 ms forever, so on
the slower CI runners a capture never found a steady element within the
step's 3 s. The page now stops replacing it after the first second, and
the step gets 5 s: early captures still have to find the replaced target
again, and a slow machine still gets a stable one in time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brynary
brynary force-pushed the element-snapshots branch from fd8e81b to 155ca09 Compare October 5, 2026 14:02
@brynary
brynary merged commit 2453baf into pointer-buttons Oct 5, 2026
3 checks passed
@brynary
brynary deleted the element-snapshots branch October 5, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant