The ASHOT framework from Yandex can be used for taking screenshots in Selenium WebDriver scripts for
This framework can be found on https://github.com/yandex-qatools/ashot.
The code for taking the screenshots is very straightforward:
ENTIRE PAGE
screenshot = new AShot().shootingStrategy(
new ViewportPastingStrategy(1000)).takeScreenshot(driver);
ImageIO.write(screenshot.getImage(), "PNG", new File("c:\\temp\\results.png"));
SPECIFIC WEB ELEMENT
screenshot = new AShot().takeScreenshot(driver,
driver.findElement(By.xpath("(//div[@id='ct_search'])[1]")));
ImageIO.write(screenshot.getImage(), "PNG", new File("c:\\temp\\div_element.png"));
See more details and more code samples on this article.