Selenium Webdriver Appium Complete TutorialSelenium Webdriver Appium Complete Tutorial
Automation Testing
  • Tools
    • Selenium
      • Selenium Java Tutorial
      • Selenium C# Tutorial
    • Appium
      • Appium Java Tutorial
      • Appium C#Tutorial
    • Katalon
  • Trainings
  • TestNG
  • Reports
    • Extent Reports
      • Extent Reports – Java
      • Extent Reports – Java -Version3
      • Extent Reports – C#
    • Vigo Reports
    • AT Excel Report
  • Excel
    • Apache POI – Java
    • Excel With C#
  • Interview Questions
    • Selenium Interview Questions
    • Java Interview Questions
    • C# Interview Questions
  • Demo Site
  • Practice Site
  • More…
    • AutoIt
    • Sikuli
    • Robot Class
    • File Upload
    • ScreenShot
      • AShot
      • ShutterBug
  • About
October 22, 2018

How to Take Screenshot using Selenium ShutterBug





How to Take Screenshot using Selenium ShutterBug will discuss how we can take a screenshot of a particular website page when you work with selenium.

Need of Screenshot for Automated Testing:

From my own experience, getting screenshots from an automation framework whenever an automated test has problems or points of failure is a very helpful feature. This ability can visually indicate a bug or malfunction in the application’s code, a problem in the design of the test, or other types of irregularities. Selenium’s API provides the necessary code for adding this capability. Along with that we have different third part API’s which supports screenshot feature in selenium. Out of those Ashot is one of the familiar way which we discussed earlier.

Why ShutterBug?

Here is one more pretty easy way to take screenshot using ShutterBug. Beauty for shutterbug is Ultimate. It can do many cool features like Taking screenshot for particular element, Comparing different screens in run time, Marking particular element during screenshot , Blurring the image.. etc . Let’s go in detail of each about shutterbug.





To start with it , Add below dependency to maven project  or Download jar files here.

<!-- https://mvnrepository.com/artifact/com.assertthat/selenium-shutterbug -->
<dependency>
    <groupId>com.assertthat</groupId>
    <artifactId>selenium-shutterbug</artifactId>
    <version>0.9</version>
</dependency>

Syntax:

Shutterbug.shootPage(<driver>).save();

In above syntax, shoot page is a method which captures the visible area on browser . Save method creates a folder with folder name as  “screenshots” in run time and saves screenshot with name as “date and timestamp” in png format.

Sample Code:

public class ShutterbugScreenshot {

@Test
public void takeScreenshot()
{
    WebDriverManager.chromedriver().setup();
    WebDriver driver = new ChromeDriver();
    driver.get("https://automationtesting.in");
    Shutterbug.shootPage(driver).save();
    driver.quit();
  }
}





However, We can get screenshot with our desired name in shutterbug.

Syntax:

Shutterbug.shootPage(<driverobject>). withName(<desiredname>).save();

In above syntax, shoot page is a method which captures the visible area on browser . withName method assigns desired name to screenshot take by shootpage method.Save method creates a folder with folder name as  “screenshots” and saves screenshot in that folder.

Sample Code:

public class ShutterbugScreenshotwithName {

@Test
public void takeScreenshotwithDesiredName()
{
      WebDriverManager.chromedriver().setup();
      WebDriver driver = new ChromeDriver();
            	
      driver.get("https://automationtesting.in");
      Shutterbug.shootPage(driver).withName("automationtestingscreenshot").save();
      driver.quit();
  }
}

“Shutterbug.shootPage(driver).withName(“automationtestingscreenshot”).save()” — will take screenshot and saves it with “automationtestingscreenshot” name.

We can do many more with shutterbug. Please go through our next blogs to learn more on Shutterbug.

Reference Link:

https://github.com/assertthat/selenium-shutterbug



Share this post: on Twitter on Facebook

No More Driver EXE files for Selenium Execution – Instead Use WebDriverManager How to Take WebElement Screenshot using Selenium ShutterBug

Related Posts

image comparison

ShutterBug

Image Comparison Using Selenium Shutterbug

full page screenshot

ShutterBug

How to Take Full Page Screenshot using Selenium ShutterBug

How to Take WebElement Screenshot using Selenium ShutterBug

ShutterBug

How to Take WebElement Screenshot using Selenium ShutterBug

Newsletter

Recent Posts

  • TAKING WEB ELEMENT SCREENSHOT IN SELENIUMHow to Capture WebElement Screenshot in Selenium Webdriver using selenium 4
    December 15, 2019
  • How To SWAP Two Numbers in Java Without using Temp VariableHow to SWAP Two Numbers in Java Without Temp variable or Without Third variable
    December 8, 2019
  • How to Swap Two Numbers in Java with Temp VariableHow to SWAP Two Numbers in Java using Temp Variable
    December 1, 2019
  • How to Read Properties file in JavaHow to Read Data From Properties File in Java
    November 27, 2019
  • Compare two arrays in java with out inbuilt functionsHow to Compare Two Arrays in Java without built-in functions
    November 16, 2019
© Selenium Webdriver Appium Complete Tutorial 2025