Take Whole Page Screenshot using AShot - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Tuesday, 6 February 2018

Take Whole Page Screenshot using AShot

Download Maven Dependency
    <dependency>
            <groupId>ru.yandex.qatools.ashot</groupId>
            <artifactId>ashot</artifactId>
            <version>1.4.12</version>
        </dependency>


package com.neeraj.test.neeraj;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.screentaker.ViewportPastingStrategy;

public class ok {

    public static WebDriver driver = new ChromeDriver();

    @Test
    public void add1() throws InterruptedException, IOException{

        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");

        driver.get("http://www.vpl.ca");

        //take the screenshot of the entire home page and save it to a png file
        Screenshot screenshot = new AShot().shootingStrategy(new ViewportPastingStrategy(1000)).takeScreenshot(driver);
        ImageIO.write(screenshot.getImage(), "PNG", new File("c:\\screenshots\\home.png"));

       
       
    }

}

3 comments:

  1. it does not take the full horizontal screenshot but takes full vertical with scrolling

    ReplyDelete
  2. The import ru.yandex.qatools.ashot.screentaker cannot be resolved

    ReplyDelete
  3. Helpful pest control strategies shared. Endeavor Pest Control

    ReplyDelete