Пример #1
0
  @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");
 }