org.openqa.selenium.WebDriverException#getCause ( )源码实例Demo

下面列出了org.openqa.selenium.WebDriverException#getCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Selenium-Foundation   文件: ScreenshotUtils.java
/**
 * Produce a screenshot from the specified driver.
 * 
 * @param optDriver optional web driver object
 * @param reason impetus for capture request; may be 'null'
 * @param logger SLF4J logger object; may be 'null'
 * @return screenshot artifact; if capture fails, an empty byte array is returned
 */
public static byte[] getArtifact(
                final Optional<WebDriver> optDriver, final Throwable reason, final Logger logger) { //NOSONAR
    
    if (canGetArtifact(optDriver, logger)) {
        try {
            WebDriver driver = optDriver.get();
            return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
        } catch (WebDriverException e) {
            if (e.getCause() instanceof ClassCastException) {
                return proxyArtifact();
            } else if (logger != null) {
                logger.warn("The driver is capable of taking a screenshot, but it failed.", e);
            }
        }
    }
    return new byte[0];
}
 
源代码2 项目: qaf   文件: QAFExtendedWebDriver.java
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;
}
 
源代码3 项目: qaf   文件: QAFWebDriverCommandProcessor.java
public String extractScreenShot(WebDriverException e) {
	Throwable cause = e.getCause();
	if (cause instanceof ScreenshotException) {
		return ((ScreenshotException) cause).getBase64EncodedScreenshot();
	}
	return null;
}
 
源代码4 项目: hsac-fitnesse-fixtures   文件: SeleniumHelper.java
/**
 * Check whether exception indicates connection with webdriver is lost.
 * @param e exception caught
 * @return true if exception indicated we can no longer communicate with webdriver.
 */
public boolean exceptionIndicatesConnectionLost(WebDriverException e) {
    boolean result = e.getCause() instanceof SocketException;
    if (!result && e.getMessage() != null) {
        result = e.getMessage().contains("java.net.SocketException")
                || e.getMessage().contains("java.net.ConnectException");
    }
    return result;
}
 
源代码5 项目: selenium   文件: XpiDriverService.java
/**
 * 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());
  }
}
 
源代码6 项目: selenium   文件: JettyAppServer.java
private void addJsResourceHandler(String handlerPath, String dirPath) {
  Path path;
  try {
    path = locate(dirPath);
  } catch (WebDriverException e) {
    // Ugly hack to get us started with bazel while sorting out missing data dependencies.
    if (Boolean.getBoolean(getClass().getPackage().getName() + ".ignoreMissingJsRoots")
        && e.getCause() instanceof FileNotFoundException) {
      System.err.println("WARNING: failed to add resource handler " + handlerPath + ": " + e.getCause());
      return;
    }
    throw e;
  }
  addResourceHandler(handlerPath, path);
}