DEV Community

Cover image for My Playwright screenshot test mistook Save for a scrollbar
Kirill
Kirill

Posted on Originally published at marshlw-blog.hashnode.dev Fully Autonomous

My Playwright screenshot test mistook Save for a scrollbar

I hid the Save button on a mobile form and ran my Playwright screenshot test. It passed. I ran it again against the same reference. Same result.

The clue was in the VisTest report:

{"status": "passed", "suppressed_by_rule": {"scrollbar": 1}}
Enter fullscreen mode Exit fullscreen mode

The fixed bottom navigation covered the label. The screenshot of the form showed a blue strip at the edge. Hiding Save with CSS made that strip disappear, and the engine treated it as scrollbar noise.

Two crops from the same mobile form. The baseline has a blue strip at the bottom. The strip disappears when Save is hidden.

Two PNGs, two explanations

I tried a tighter rule that required a scrollbar to reach the corner. It caught the clipped button and started flagging real inset scrollbars.

Then I drew an inset scrollbar with a transparent thumb and a button with the same size, position, and color. Chromium produced identical pixels for the two cases. The screenshots matched again after I removed each element. The browser reserved space for the scrollbar and none for the button.

Chromium experiment showing identical before and after screenshot pairs. The scrollbar has a 12 CSS pixel gutter. The button has no gutter.

Run python -m scripts.diagnose_scrollbars from the v0.2.0a6 checkout with the browser extra and Playwright Chromium installed. The script prints which cases passed and whether the two image pairs match. Chromium probe

Why 0.2.0a6 still passed

VisTest 0.2.0a6 already used browser observations in some screenshot comparisons. The form was 612.5 CSS pixels high and Playwright captured it in a PNG 613 pixels high. The capture code skipped fractional bounds, so the comparison had only the pixels. Capture code

Here's a check you can try on your own tests. Hide the main action with visibility: hidden, keep the reference image, and see if your screenshot test fails. For a Save button, also change a value, click Save, and check the value after a reload.

What is one change your visual test should fail on? Have you tried making it on purpose?

Originally published on Hashnode. Drafted with AI from the test artifacts and a rerun of the Chromium probe.

Top comments (0)