public boolean saveScreenshotTo(String path) { WebDriver driver = get(); if (driver instanceof TakesScreenshot) { File file = new File(path); byte[] bytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); file.getParentFile().mkdirs(); try { file.createNewFile(); IOUtils.write(bytes, new FileOutputStream(file)); } catch (IOException e) { throw new RuntimeException("Can't save file", e); } return true; } return false; }
public boolean saveScreenshotTo(String path) { WebDriver driver = get(); if (driver instanceof TakesScreenshot) { File file = new File(path); byte[] bytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); file.getParentFile().mkdirs(); try { file.createNewFile(); IOUtils.write(bytes, new FileOutputStream(file)); } catch (IOException e) { throw new RuntimeException("Can't save file", e); } return true; } return false; }