protected String extractScreenShot(final WebDriverException e) { final Throwable cause = e.getCause(); if (cause instanceof ScreenshotException) { return ((ScreenshotException) cause).getBase64EncodedScreenshot(); } return null; }
public SerenityWebDriverException(WebDriverException testErrorException) { super(testErrorException.getCause()); this.detailedMessage = testErrorException.getMessage(); this.stackTrace = testErrorException.getStackTrace(); this.cause = testErrorException.getCause(); this.exceptionClass = testErrorException.getClass(); }
@Override public Number execute(Context context, String... args) { String cssLocator = args[ARG_CSS_LOCATOR]; if (!cssLocator.startsWith(CSS_EQ)) cssLocator = CSS_EQ + cssLocator; try { List<WebElement> elements = context.findElements(cssLocator); return elements.size(); } catch (WebDriverException e) { if (e instanceof NoSuchElementException || e.getCause() instanceof NoSuchElementException) return 0; throw e; } } }
/** * Check if the Sizzle library is loaded. * * @return the true if Sizzle is loaded in the web page */ public Boolean sizzleLoaded() { Boolean loaded = true; try { loaded = (Boolean) ((JavascriptExecutor) getDriver()) .executeScript("return (window.Sizzle != null);"); } catch (WebDriverException e) { LOG.error("while trying to verify Sizzle loading, WebDriver threw exception {} {}",e.getMessage(),e.getCause() != null ? "with cause "+e.getCause() : ""); loaded = false; } return loaded; }
/** * Configures and returns a new {@link XpiDriverService} using the default configuration. In * this configuration, the service will use the firefox executable identified by the * {@link FirefoxDriver.SystemProperty#BROWSER_BINARY} system property on a free port. * * @return A new XpiDriverService using the default configuration. */ public static XpiDriverService createDefaultService() { try { return new Builder().build(); } catch (WebDriverException e) { throw new IllegalStateException(e.getMessage(), e.getCause()); } }
supportsElementScreenshots = false; } catch (WebDriverException e) { if (e.getCause() instanceof UnsupportedCommandException) { supportsElementScreenshots = false; } else {
LOGGER.debug("waitUntil: WebDriverException e..." + getNameWithLocator()); result = false; originalException = e.getCause();
&& e.getCause() instanceof NoSuchElementException) // issue #104: do not log error when waitForPresent raises TimeoutException || (e instanceof NoSuchElementException
/** * Quits Selenium WebDriver instance managed by this class. */ public static void closeDriver() { if (getCurrentDriver() != null) { try { quitDriver(); } catch (WebDriverException ex) { if (ex.getCause() instanceof InterruptedException) { logInfo("attempting to close driver again after InterruptedException."); logDebug("attempting to close driver after InterruptedException.", ex); quitDriver(); } else { String msg = "Exception when closing driver."; logError(msg, ex); throw new SkipException("Skipping test because of driver problems. ", ex); } } finally { setDriver(null); setTestDevice(null); logInfo("Driver and Device set to null"); } } else { logDebug("Unnecessary call to close driver.", new GaleniumException("Attempting to close non existent driver.")); } }