Selenium Take Full Page Screenshot

Profile picture for user arilio666

Taking a full screenshot of a page in selenium java is not possible, but we can get around a jar file which might help us take a beautiful screenshot of the whole page.

To do this, we need to use a third-party library called Ashot. Taking a screenshot using this is flawless and has more capability options than the original screenshot capability from selenium.

1.) POM

  • Add this XML to your pom.xml file, and this will install all the necessary jars for ashot to take over.

2.) Example screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
  • This is how we need to initiate Ashot and set the shooting strategy to the viewport value of 1000 and then take screenshot options are passed with the casting of the driver.
ImageIO.write(screenshot.getImage(), "PNG", new File("C:\\TestLeaf\\fullPage.png"));
  • We are using the ImageIO to write the screenshot after getting the image and fixing the extension along with the path for storing the file.
        ChromeDriver driver = new ChromeDriver();
        driver.manage().window().maximize(); screenshot = new AShot()
        try {
            ImageIO.write(screenshot.getImage(), "PNG", new File("C:\\TestLeaf\\fullPage.png"));
        } catch (IOException e) {
            // TODO Auto-generated catch block
  • Here we can see the full-view screenshot taken by Ashot.