question: public static void takeScreenshot ( final String tag ) { if ( scenario == null ) { throw new ScreenshotException ( "Error taking screenshot: I'm missing a valid test scenario to attach the screenshot to" ) ; } SpoonScreenshotAction . perform ( tag ) ; final File screenshot = SpoonScreenshotAction . getLastScreenshot ( ) ; if ( screenshot == null ) { throw new ScreenshotException ( "Screenshot was not taken correctly, check for failures in screenshot library" ) ; } FileInputStream screenshotStream = null ; try { screenshotStream = new FileInputStream ( screenshot ) ; final byte fileContent [ ] = new byte [ ( int ) screenshot . length ( ) ] ; final int readImageBytes = screenshotStream . read ( fileContent ) ; if ( readImageBytes != - 1 ) { scenario . embed ( fileContent , "image/png" ) ; } } catch ( final IOException ioe ) { throw new ScreenshotException ( "Exception while reading file " + ioe ) ; } finally { try { if ( screenshotStream != null ) { screenshotStream . close ( ) ; } } catch ( final IOException ioe ) { throw new ScreenshotException ( "Error while closing screenshot stream: " + ioe ) ; } } }
target:  Take a screenshot of the current activity and embed it in the HTML report