0

我要截屏的 URL 是https://www.smashingmagazine.com/2017/05/long-scrolling/ 附件是从 Ashot 获得的截屏。[截图来自 ashot] - https://i.stack.imgur.com/CdeYf.jpg(注意它不完整)

我觉得这是一个内存问题,而不是一个错误。任何指针将不胜感激。

这是我用来截屏的代码。

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();
    }
}
4

0 回答 0