Taking full page screen shot of really long webpages using Ashot, Selenium Java Client, ChromeDriver

446 Views Asked by At

the URL i am trying to take a screenshot is https://www.smashingmagazine.com/2017/05/long-scrolling/ Attached is the screenshot obtained from Ashot. [screenshot from ashot] - https://i.stack.imgur.com/CdeYf.jpg (notice it is incomplete)

I feel like its a memory issue and not a bug. Any pointers would be appreciated.

This is the code I am using to take screenshots.

import java.io.File;
import javax.imageio.ImageIO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;

public class ashot_CompletePage {

    public static void main(String[] args) throws Exception {

        System.setProperty("god.bless.you", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("start-maximized");
        options.addArguments("disable-infobars");
        options.addArguments("--disable-extensions"); 
        WebDriver driver =  new ChromeDriver(options);
        driver.get("https://www.smashingmagazine.com/2017/05/long-scrolling/");
        new WebDriverWait(driver, 20).until(ExpectedConditions.titleContains("jQuery"));
        Screenshot myScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(driver);
        ImageIO.write(myScreenshot.getImage(),"PNG",new File("./Screenshots/elementScreenshot.png"));
        driver.quit();
    }
}
0

There are 0 best solutions below