Skip to content

docs: note device-pixel vs CSS-pixel mismatch in screenshots#201

Open
sauravpanda wants to merge 1 commit intomainfrom
docs/screenshot-dpr
Open

docs: note device-pixel vs CSS-pixel mismatch in screenshots#201
sauravpanda wants to merge 1 commit intomainfrom
docs/screenshot-dpr

Conversation

@sauravpanda
Copy link
Copy Markdown
Collaborator

@sauravpanda sauravpanda commented Apr 25, 2026

Summary

  • capture_screenshot() writes PNGs at device pixels but click_at_xy() takes CSS pixels — on a 2x display, reading a coordinate off the image and clicking it directly misses by half.
  • Flesh out interaction-skills/screenshots.md with the conversion recipe and the discovery-vs-verification distinction, and add a docstring to click_at_xy pointing at it.

Verification

Confirmed the gap empirically before writing the doc:

screenshot pixels: (4592, 2286)
window: {"dpr":2,"iw":2296,"ih":1143}

Then dropped a 60×60 button at CSS (180,180) and clicked twice:

  • click_at_xy(210, 210) → click registered (CSS coord inside button) ✅
  • click_at_xy(420, 420) → no click (device-pixel coord, lands well outside) ❌

So click_at_xy definitively takes CSS pixels, and the previous screenshots.md (one sentence) didn't say so.

Test plan

  • browser-harness -c "print(click_at_xy.__doc__)" shows the new docstring
  • Helpers still import and page_info() still works
  • Reviewer skim of interaction-skills/screenshots.md for tone/scope

Summary by cubic

Clarify the device‑pixel vs CSS‑pixel mismatch between capture_screenshot() and click_at_xy(), and add a docstring that points to a short conversion recipe in interaction-skills/screenshots.md. This prevents off‑by‑DPR clicks on HiDPI/Retina displays and explains when to use full‑page vs viewport screenshots.

Written for commit dcd8137. Summary will update on new commits.

capture_screenshot() saves PNGs at device pixels, but click_at_xy()
takes CSS pixels. On a HiDPI / Retina display that's a 2x factor —
reading a coordinate off the screenshot and clicking it directly
misses by half. Document the conversion in interaction-skills/screenshots.md
and add a docstring to click_at_xy pointing at it.
@browser-harness-review
Copy link
Copy Markdown

✅ Skill review passed

Reviewed 1 file(s) — no findings.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

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