1

I want to take Screenshot of the web-page at Runtime while screen-scraping with HtmlUnit or Jsoup in Java.

Is there any way to do so?

3 Answers3

1

HtmlUnit does not render the elements. It is GUI-less (headless) browser.

Please find sample code using WebDriver/Selenium here.

Community
  • 1
  • 1
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
0

This item may be helpful. It uses java.awt.Robot to take a screen shot and save it to disk.

Previous Answer - Java Screen Shot

Community
  • 1
  • 1
AhDev
  • 486
  • 11
  • 16
-1

Try this one Robot#createScreenCapture().

BufferedImage image = new Robot().createScreenCapture(newRectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", new File("/screenshot.png"));
Altay Mazlum
  • 442
  • 5
  • 15