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"));
}
}
<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"));
}
}
it does not take the full horizontal screenshot but takes full vertical with scrolling
ReplyDeleteThe import ru.yandex.qatools.ashot.screentaker cannot be resolved
ReplyDelete