コード例 #1
0
ファイル: Augmenter.java プロジェクト: nvreynolds/selenium
  @Override
  protected RemoteWebDriver extractRemoteWebDriver(WebDriver driver) {
    if (driver.getClass().isAnnotationPresent(Augmentable.class)
        || driver
            .getClass()
            .getName()
            .startsWith("org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByCGLIB")) {
      return (RemoteWebDriver) driver;

    } else {
      logger.warning(
          "Augmenter should be applied to RemoteWebDriver instances "
              + "or previously augmented instances only");
      return null;
    }
  }
コード例 #2
0
 private boolean driverCanTakeSnapshots() {
   if (driver == null) {
     return false;
   } else if (driver instanceof WebDriverFacade) {
     return ((WebDriverFacade) driver).canTakeScreenshots()
         && (((WebDriverFacade) driver).getProxiedDriver() != null);
   } else {
     return TakesScreenshot.class.isAssignableFrom(driver.getClass());
   }
 }
コード例 #3
0
  private void savePageSourceFor(final String screenshotFile) throws IOException {
    if (WebDriver.class.isAssignableFrom(driver.getClass())) {
      try {
        WebDriver webdriver = driver;
        String pageSource = webdriver.getPageSource();

        File savedSource = new File(sourceCodeFileFor(screenshotFile));
        FileUtils.writeStringToFile(savedSource, pageSource);
      } catch (WebDriverException e) {
        getLogger().warn("Failed to save screen source code", e);
      }
    }
  }
コード例 #4
0
 public static boolean isMobile(WebDriver driver) {
   if (driver instanceof WebDriverFacade) {
     return ((WebDriverFacade) driver).getDriverClass().isAssignableFrom(AppiumDriver.class);
   }
   return (driver.getClass().isAssignableFrom(AppiumDriver.class));
 }
コード例 #5
0
 public static WebDriver unwrap(WebDriver wrapped) {
   if (WrapsDriver.class.isAssignableFrom(wrapped.getClass())) {
     return unwrap(((WrapsDriver) wrapped).getWrappedDriver());
   } else return wrapped;
 }
コード例 #6
0
 private boolean isAMock(WebDriver driver) {
   return driver.getClass().getCanonicalName().contains("Mock");
 }