top of page
  • Writer's pictureGlib Briia

Mastering Full-Page Screenshots in Chrome with Selenium and AssertThat

Updated: Nov 22, 2023

Mastering Full-Page Screenshots in Chrome with Selenium and AssertThat

Discover the simplicity of capturing full-page screenshots in Chrome using Selenium WebDriver and AssertThat's selenium-shutterbug. This guide provides an easy one-line Java solution, perfect for enhancing your automated testing processes.

Understanding WebDriver Screenshot Definitions

WebDriver offers two primary approaches for screenshots. The first captures the entire DOM of the loaded page, as seen in Firefox and IE drivers. The second, defined in the W3C WebDriver specification, captures only the top-level browsing context's viewport, a method ChromeDriver adheres to, sparking debate over the most effective approach.

How to Capture Full-Page Screenshots in Chrome

Despite differing definitions, obtaining full-page screenshots is essential for comprehensive testing. Use this simple line of code with AssertThat's selenium-shutterbug for capturing full-page images in Chrome and other browsers:

Shutterbug.shootPage(driver, ScrollStrategy.BOTH_DIRECTIONS).save();

Updates and Enhancements with Chrome 64 and Shutterbug v.0.8

Chrome 64's update introduced Page.captureScreenshot in Chrome DevTools for full-page snapshots, now integrated into shutterbug v.0.8. Utilize this latest method with

Shutterbug.shootPage(driver, ScrollStrategy.WHOLE_PAGE_CHROME,  true).save();

For users of Chrome version 64 or older, the scrolling method remains viable.

Shutterbug.shootPage(driver, ScrollStrategy.BOTH_DIRECTIONS, 500, true).save();

Further Information and Installation Guide

For detailed installation instructions and more on using selenium-shutterbug, visit our comprehensive guide. Stay updated with the latest in automated browser testing techniques and tools.

692 views0 comments


bottom of page