File tmpfile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
try {
FileHandler.copy(tmpfile, file);
} catch (IOException e) {
throw new CrawljaxException(e);
}
removeCanvasGeneratedByFirefoxDriverForScreenshots();
} else if (driver instanceof RemoteWebDriver) {
WebDriver augmentedWebdriver = new Augmenter().augment(driver);
takeScreenShotOnBrowser(augmentedWebdriver, file);
} else if (driver instanceof WrapsDriver) {
takeScreenShotOnBrowser(((WrapsDriver) driver).getWrappedDriver(), file);
} else {
throw new CrawljaxException("Your current WebDriver doesn't support screenshots.");
}
}