org.openqa.selenium.remote.ScreenshotException Java Examples
The following examples show how to use
org.openqa.selenium.remote.ScreenshotException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ATHJUnitRunner.java From blueocean-plugin with MIT License | 5 votes |
private void writeScreenShotCause(Throwable t, Object test, FrameworkMethod method) throws IOException { WebDriver driver = injector.getInstance(WebDriver.class); File file = new File("target/screenshots/"+ test.getClass().getName() + "_" + method.getName() + ".png"); Throwable cause = t.getCause(); boolean fromException = false; while(cause != null) { if(cause instanceof ScreenshotException) { ScreenshotException se = ((ScreenshotException) cause); byte[] screenshot = Base64.getMimeDecoder().decode(se.getBase64EncodedScreenshot()); Files.createParentDirs(file); Files.write(screenshot, file); logger.info("Wrote screenshot to " + file.getAbsolutePath()); fromException = true; break; } else { cause = cause.getCause(); } } if(!fromException) { File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, file); logger.info("Wrote screenshot to " + file.getAbsolutePath()); } }
Example #2
Source File: QAFExtendedWebDriver.java From qaf with MIT License | 5 votes |
public <T> T extractScreenShot(WebDriverException e, OutputType<T> target) { if (e.getCause() instanceof ScreenshotException) { String base64Str = ((ScreenshotException) e.getCause()).getBase64EncodedScreenshot(); return target.convertFromBase64Png(base64Str); } return null; }
Example #3
Source File: QAFWebDriverCommandProcessor.java From qaf with MIT License | 5 votes |
public String extractScreenShot(WebDriverException e) { Throwable cause = e.getCause(); if (cause instanceof ScreenshotException) { return ((ScreenshotException) cause).getBase64EncodedScreenshot(); } return null; }
Example #4
Source File: SeleniumHelper.java From hsac-fitnesse-fixtures with Apache License 2.0 | 5 votes |
/** * Finds screenshot embedded in throwable, if any. * @param t exception to search in. * @return content of screenshot (if any is present), null otherwise. */ public byte[] findScreenshot(Throwable t) { byte[] result = null; if (t != null) { if (t instanceof ScreenshotException) { String encodedScreenshot = ((ScreenshotException)t).getBase64EncodedScreenshot(); result = Base64.getDecoder().decode(encodedScreenshot); } else { result = findScreenshot(t.getCause()); } } return result; }