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

Run JavaScript in the page to pause animations, then take the screenshot with your Selenium binding. To freeze animations where they are now, use document.getAnimations().forEach(animation => animation.pause()); this pauses each animation at its current time rather than choosing a particular keyframe.

Pause animations before taking the screenshot

Wait until the page is in the state you want to capture, execute the pause script, and then take the screenshot. For Python Selenium:

driver.execute_script("document.getAnimations().forEach(animation => animation.pause());")
driver.save_screenshot("page.png")

document.getAnimations() returns animations in effect on document descendants, including CSS Animations, CSS Transitions, and Web Animations. The browser-side Web Animations API provides playback control for these animation types. See MDN: Document.getAnimations().

Pausing suspends playback at the time the pause takes effect. It does not choose a named keyframe or guarantee the same image across separate runs. If a test needs a particular frame, use a page-specific test mode or another controlled way to set the animation time, and verify that setup for the site and browser you test.

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

Use the screenshot method for your Selenium binding

Keep the same sequence in other languages: execute the JavaScript in the page, then call the binding’s screenshot method. Selenium’s JavaScript API documents takeScreenshot() as returning a Base64-encoded PNG string. Selenium’s Java documentation shows getScreenshotAs(OutputType.FILE). Consult the API documentation for your binding for exact setup and file-writing details.

Handle timing and coverage edge cases

  • Pause only after the page is ready. The script freezes current animation times, so run it after the page has reached the visual state you intend to capture. Readiness conditions depend on the site; a generic delay does not establish that all content is ready.
  • Be aware of unresolved animation time. MDN documents that Animation.pause() can throw InvalidStateError when currentTime is unresolved and the animation’s end time is positive infinity. If that occurs, inspect the page’s animations and handle the affected animation according to the site’s behavior. See MDN: Animation.pause().
  • Check shadow-root content separately. The documented query covers animations associated with document descendants. Pages that render relevant content inside shadow roots may require page-specific verification; do not assume this one document-level query covers every such animation.
  • Capture promptly. Animations created after the script runs are not paused by that earlier call. If the page starts new animations during capture, rerun the pause step at the appropriate point.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you want a screenshot API instead of managing Selenium and browser setup, ScreenshotNeo takes a URL in one GET request. For example, this cURL command saves a WebP screenshot of Stripe:

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 documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for free.

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.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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