protected long timestamp() {
return System.currentTimeMillis();
}
public String takeScreenShot(String fileName) {
WebDriver webdriver = getWebDriver();
if (webdriver == null) {
System.err.println("Cannot take screenshot because browser is not started");
return null;
}
File targetFile = new File(reportsFolder, fileName + ".html");
try {
writeToFile(webdriver.getPageSource(), targetFile);
} catch (Exception e) {
System.err.println(e);
}
if (webdriver instanceof TakesScreenshot) {
targetFile = takeScreenshotImage((TakesScreenshot) webdriver, fileName, targetFile);
}
else if (webdriver instanceof RemoteWebDriver) {
WebDriver remoteDriver = new Augmenter().augment(webdriver);
if (remoteDriver instanceof TakesScreenshot) {
targetFile = takeScreenshotImage((TakesScreenshot) remoteDriver, fileName, targetFile);
}
}