Skip to end of metadata
Go to start of metadata

Taking a screenshot of the desktop is quite simple. The class ScreenshotTaker provides two methods:

  1. takeDesktopScreenshot() takes a screenshot of the desktop and returns it as a java.awt.image.BufferedImage.
  2. saveDesktopAsPng(String) takes a screenshot of the desktop and saves it as a PNG image using the file path passed as argument.

Example

The following example takes a screenshot of the desktop when a test fails and saves the image as "myTest.png":