Scrollable screenshot using ashot in selenium not working with internet explorer 11 version but working fine in chrome and firefox

1.8k views Asked by At
    public static void takeScrollableScreenshot(WebDriver webdriver, String filePath, WebDriverWait wait) throws Exception
      {
    File myDirectory = new File(filePath);
    if(!myDirectory.exists()) {
       myDirectory.mkdirs(); 
    }else{
       // Directory already exist
    }

    Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(500))
            .takeScreenshot(webdriver);

    ImageIO.write(screenshot.getImage(), "PNG", myDirectory);

}

sample output

1

There are 1 answers

6
dangi13 On

You can use below method to take full page screenshot in IE :

/**
     * @param driver
     * @param file e.g "C:\\Users\\username\\Desktop\\RegressionTests\\oracle.png"
     * @throws IOException
     */
    public static void takeScreenshot(WebDriver driver, String file) throws IOException {
         ((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");
         File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
         FileUtils.copyFile(scrFile, new File(file));
     }

Hope that helps you:)