@Override public Object screenshot(String url, String description) { Screenshot screenshot = factory.createScreenshot(); screenshot.setUrl(url); screenshot.setDescription(description); return screenshot; }
@Override public Object screenshot(TakesScreenshot takesScreenshot, String description) { Screenshot screenshot = factory.createScreenshot(); screenshot.setDescription(description); File tempFile = takesScreenshot.getScreenshotAs(OutputType.FILE); File attachmentFile = null; try { attachmentFile = LogFileAttachment.getAttachmentFile("", "png"); FileUtils.copyFile(tempFile, attachmentFile); } catch (IOException e) { e.printStackTrace(); } if (attachmentFile != null) screenshot.setUrl(attachmentFile.getName()); return screenshot; }