Stabilize screenshots
A playbook for tackling visual flakiness, with detection, ignoring noisy changes, and stabilization strategies.
The most reliable visual test suite is one where flakiness is fixed at the source. This playbook covers the strategies that make screenshots deterministic — from waiting for loading to freezing dynamic values.
Common causes
Visual flakiness usually stems from one of the following:
Dynamic content: Ads, user-generated content, or other data that changes between runs.
Asynchronous loading: Elements or styles that render at inconsistent times.
Rendering differences: Browser, OS, or device variations that alter visual output.
External dependencies: Reliance on third-party systems that introduce variability.
Animations and transitions: Unhandled motion captured mid-frame.
Resolution and scaling: Screen size or pixel density differences between environments.
Best practices for stable screenshots
Follow these practices — each one targets a common cause above:
Wait until the page is ready before capturing. Mark loading elements with
aria-busysoargosScreenshot()waits for them. → Wait for loadingWait for CSS background images to load. Flag elements with
data-visual-test-wait-bg-imgso Argos waits for their backgrounds — or extend the check to the whole page. → Wait for background imagesFreeze animated GIFs. GIFs are paused on their first frame by default so they don't capture a random frame on each run. → Pause animated GIFs
Make dates and times deterministic. Hide or freeze any value that changes between runs. → Stabilize date & time
Force consistent text rendering. Disable subpixel text and font hinting so glyphs look identical on every machine. → Stabilize text rendering
Run the same environment everywhere, and tame rendering quirks. Use the same OS and browser locally and on CI, and smooth over properties like
border-radius. → Browser glitchesMask or hide unavoidable dynamic content. Use
data-visual-testattributes for anything you can't stabilize at the source. → Argos helpers
New to visual testing? Start with Stabilize text rendering and Wait for loading. Together they prevent the large majority of flaky screenshots.
Emphasis on accessibility
At Argos, we advocate for accessibility-focused end-to-end testing. Improving accessibility (semantic markup, aria-busy, predictable focus states) not only supports users with disabilities but also makes tests more deterministic and less prone to flakiness.
Last updated
Was this helpful?