Taking a screenshot of the desktop is quite simple. The class ScreenshotTaker provides two methods:
takeDesktopScreenshot()takes a screenshot of the desktop and returns it as ajava.awt.image.BufferedImage.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":
Labels