private void saveScreenshotTo ( final File file ) throws IOException { byte [ ] bytes = null ; try { bytes = ( ( TakesScreenshot ) driver ) . getScreenshotAs ( OutputType . BYTES ) ; } catch ( ClassCastException e ) { WebDriver augmentedDriver = new Augmenter ( ) . augment ( driver ) ; bytes = ( ( TakesScreenshot ) augmentedDriver ) . getScreenshotAs ( OutputType . BYTES ) ; } Files . write ( bytes , file ) ; }
Saves the screenshot to the file .