October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Disable CSS Animations in Visual Regression Screenshots

Playwright’s screenshot assertion can disable CSS animations, transitions, and Web Animations during capture. Learn how to set it per screenshot or project-wide, when to use reduced-motion emulation, and what else affects visual stability.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For Playwright Test screenshot assertions, set animations: 'disabled' in toHaveScreenshot(). It disables CSS animations, CSS transitions, and Web Animations during capture, helping prevent motion from making otherwise identical screenshots differ.

Disable animations in one Playwright screenshot

Pass the option to the screenshot assertion. This TypeScript example captures the page after navigating to its root URL:

As an Amazon Associate I earn from qualifying purchases.

import { test, expect } from '@playwright/test';

test('page renders without animation interference', async ({ page }) => {
  await page.goto('/');
  await expect(page).toHaveScreenshot('homepage.png', {
    animations: 'disabled',
  });
});

Playwright documents that animations: 'disabled' stops CSS animations, CSS transitions, and Web Animations. Finite animations are fast-forwarded to completion, which fires transitionend. Infinite animations are canceled to their initial state for the screenshot, then played over afterward. So the option does not simply remove every animation rule or leave all animations at an arbitrary midpoint. Playwright PageAssertions API

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the default for screenshot assertions

If you want the setting on every toHaveScreenshot() assertion in a Playwright Test project, configure it in playwright.config.ts:

#1 Best Overall
Sale
The IXL Ultimate 3rd Grade Math Workbook, Activity Book for Kids Ages 8-9 Covering Addition, Subtraction, Multiplication, Division, Fractions, Geometry, and More Mathematics (IXL Ultimate Workbooks)
  • Carefully designed questions: Ensuring a solid understanding of concepts
  • Engaging activities: Offering a mix of enjoyable exercises
  • Problem-solving techniques: Providing strategies for tackling challenges
  • Vibrant, full-color visuals: Enhancing learning with captivating illustrations
import { defineConfig } from '@playwright/test';

export default defineConfig({
  expect: {
    toHaveScreenshot: {
      animations: 'disabled',
    },
  },
});

Check the API documentation for the Playwright version installed in your project before adopting an option; screenshot assertion APIs and documented defaults are versioned.

Choose between a stable screenshot and reduced-motion behavior

These settings address different test goals:

  • animations: 'disabled' makes a screenshot capture stable by stopping motion during that screenshot operation.
  • reducedMotion: 'reduce' emulates the prefers-reduced-motion media feature, allowing you to test how your page responds to a user preference for minimizing non-essential movement. Playwright browser context API

For example, a site might reduce or remove a specific animation when reduced motion is requested:

Rank #2
YAFIYGI Eye Chart Snellen and Rosenbaum Combo Vision Test Card for Exams Near Point Charts for Professional and Pediatric Use 2 in 1 Eye Exam Chart Set Kids Gifts Eye Exams and Vision Screening 2 PCS
  • Dual Functionality: Our Pocket Eye Chart set includes both the 2 eye charts, offering a versatile solution for measuring visual acuity at a distance and in limited spaces. This 2-in-1 design caters to various vision testing needs
  • Compact and Convenient: Sized at 6.5*3.5 inches, these pocket eye charts are designed for portability. Whether you're a professional optometrist, student, or need a handy tool for vision tests on the go, our compact pocket eye chart set fits conveniently in your pocket 
  • Color Vision Test: The eye chart features Red and Green color bars, providing an easy and helpful color vision test. This additional feature enhances the versatility of our pocket eye chart set, making it suitable for a range of vision examinations
  • Durable and Washable: Crafted from durable plastic, our pocket eye charts are built to last. The washable material ensures easy maintenance and hygiene, making them ideal for repeated use in optometry practices, schools, and offices
  • Pupil Gauge and Non-Reflective:The plastic pocket eye chart includes a pupil gauge, adding practicality to vision examinations. The non-reflective surface ensures accurate readings. This set is a reliable tool for professionals and a handy resource for quick vision assessments
@media (prefers-reduced-motion: reduce) {
  .animated-element {
    animation: none;
  }
}

The prefers-reduced-motion feature has reduce and no-preference values. A reduced-motion preference does not inherently require removing every animation; a design can reduce or replace non-essential movement. MDN: prefers-reduced-motion MDN CSS reference

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a screenshot stylesheet for custom overrides

Playwright screenshot APIs also accept a stylesheet string or path. A stylesheet can filter dynamic or volatile content to make captures more deterministic; the documented screenshot option can pierce Shadow DOM and apply styles to inner frames. Playwright PageAssertions API

One possible override is:

*,
*::before,
*::after {
  animation: none !important;
  transition: none !important;
}

Treat this as a custom pattern, not a universal fix. Broad overrides can affect the intended layout or visual state, so inspect the resulting screenshot. Application JavaScript that updates the DOM or styles independently may need app-specific synchronization; this CSS rule does not control every such update.

Stabilize the rest of the screenshot

Animation is only one source of visual variation. Playwright’s screenshot assertion waits for two consecutive page screenshots to match before comparing the result. Screenshot styles can also hide or alter dynamic content. Playwright PageAssertions API

Rank #4
Morning and Bedtime Routine Chart with 12 visual symbols pecs cards by Create Visual Aids to support routine, transition for children, autism, aspergers, ADHD, speech and language delay.
  • Creating calmer and happier mornings and bedtimes for the whole family by showing your child what they need to do to get ready.
  • Encourages independence and therefore boosts self esteem as children are no longer dependent on you reminding them what comes next.
  • Allows for processing time - the pictures, or pecs cards for autism, don't disappear like words do and therefore these are great for children with special educational needs, autism, ADHD, speech and language delay, ASD.
  • Eliminates the need for you to nag - children can see what they need to do for themselves in this routine chart.
  • Pictures cards can be moved around thanks to being attached using VELCRO Brand hook and loop, meaning you can order the routine to suit your family.

Keep the capture environment consistent as well. Playwright identifies host operating system, browser version, settings, hardware, power source, and headless mode as factors that can change screenshots. Control volatile page state and use a consistent environment when comparing baselines. Playwright visual comparisons

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting animation-related screenshot differences

  • The assertion still differs between runs: Check whether the page has changing content such as timestamps, rotating content, or asynchronously updated elements. Use an appropriate screenshot stylesheet or synchronize with the application state before capture.
  • The animation ends in an unexpected state: Finite animations are fast-forwarded, while infinite animations are canceled at their initial state for capture. Confirm that this is the visual state your test should compare.
  • Reduced-motion tests look unchanged: Confirm that the page has CSS or application behavior for prefers-reduced-motion. Emulating the preference tests the site’s response; it does not forcibly disable all animation in the way the screenshot option does.
  • A CSS override changes the page layout: Narrow the selectors or remove the override and use the screenshot assertion option. Verify that any custom stylesheet produces the intended capture.
  • Differences remain on another machine: Check for changes in operating system, browser version, browser settings, hardware, power source, or headless mode, all of which can affect rendering.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a one-request screenshot without setting up a browser test, ScreenshotNeo accepts a URL and returns an image or PDF. Its clean-shot process accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify page verdict and billing status in headers. An MCP server provides screenshot tools for AI agents, and every plan includes the features. ScreenshotNeo

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://stripe.com 
  -o shot.webp

See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.