top of page
  • Writer's pictureGlib Briia

Selenium Shutterbug - make custom screenshots with Selenium WebDriver

Overview of Selenium Shutterbug - utility library to create customized screenshots using Selenium WebDriver and Java AWT

The most important part of test automation on any project is reporting. You may have thousands of tests running on dozens of devices, operating systems, browsers, but without descriptive, clear reporting the results all this effort is no more than waste of computation time and electricity.

A significant aspect of reporting results is to make self explanatory screenshots to be able to easy identify the reason of test failure and take appropriate actions - either raise a defect or fix the test.

Selenium Shutterbug was developed with above mentioned points in mind. The idea behind the project is to make testers life easier by enabling us to create descriptive screenshots which, in some cases, could be directly attached to the bug reports or serve as a source of information about system state at a specific moment of time.

Below are some basic examples of usage:

Take screenshot and save to default location (./screenshots/):


Take screenshot and specify location to save to:


Take screenshot and scroll in both directions:

This is particularly useful while testing in Chrome, since it if following W3C definition of screenshot and takes screenshot of the top-level browsing context’s viewport only.
Shutterbug.shootPage(driver, ScrollStrategy.WHOLE_PAGE).save();

Take screenshot of specified WebElement only:

Shutterbug.shootElement(driver, element).save();

Compare screenshot taken with the expected one with specified deviation rate:


Take screenshot and save thumbnail as well (with specified resize ratio):


And many more ..

To demonstrate how it all can be pieced together the example follows:

System.setProperty("", "your path to  chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        WebElement googleLogo = driver.findElement("hplogo"));
        WebElement searchBtn = driver.findElement("sblsbb"));
        WebElement searchBox = driver.findElement(By.className("gsfi"));


                .highlightWithText(googleLogo,, 3, "Monochromed logo",, new Font("SansSerif", Font.BOLD, 20))
                .highlightWithText(searchBox, "Blurred secret words")
                .withTitle("Google home page - " + new Date())

As the result of chaining the operation on taken screenshot the following image is processed and saved to C:\testing\screenshots\

The project is available in Maven Central

Maven dependency


Using Gradle

compile 'com.assertthat:selenium-shutterbug:x.x'

Selenium Shutterbug is open source project , developed under MIT license and hosted on Github. Any contributions are highly appreciated. ‘How to contribute’ process is described here.

2,350 views0 comments

Recent Posts

See All


bottom of page