private static WebDriver getDriver(Browser browser, InputStream inputStream) throws IOException {
    AbstractBrowserConfigReader properties = null;
    if (browser == Browser.FIREFOX) {
      properties = new FirefoxConfigReader();
    } else if (browser == Browser.IEXPLORE) {
      properties = new IExplorerConfigReader();
    } else if (browser == Browser.CHROME) {
      properties = new ChromeConfigReader();
    } else if (browser == Browser.HTMLUNIT) {
      properties = new HtmlUnitConfigReader();
    } else {
      LOGGER.error("Browser not supported {}", browser);
      driver = null;
    }
    if (properties != null) {
      if (inputStream != null) {
        properties.load(inputStream);
      }
      LOGGER.info(properties.toString());

      driver = properties.createDriver();
      WebDriverConfig.setDownloadPath(properties.getDownloadPath());
      WebDriverConfig.setSilentDownload(properties.isSilentDownload());
    }
    init(driver);
    return driver;
  }
 public boolean download(String fileName, long timeoutMillis) {
   if (WebDriverConfig.isSilentDownload()) {
     fileName = WebDriverConfig.getDownloadPath() + File.separator + fileName;
     File file = new File(fileName);
     return FileUtils.waitFileIfIsEmpty(file, timeoutMillis)
         && fileName.equals(file.getAbsolutePath());
   } else {
     return RunExe.getInstance().download(fileName);
   }
 }
Beispiel #3
0
 public void pay() {
   try {
     payButton.click();
   } catch (UnhandledAlertException e) {
     LOGGER.warn("UnhandledAlertException, accept and retry", e);
     WebDriverWait wait = new WebDriverWait(WebDriverConfig.getDriver(), 10);
     wait.until(ExpectedConditions.alertIsPresent());
     WebDriverConfig.getDriver().switchTo().alert().accept();
     LOGGER.info("alert - accepted");
     payButton.click();
   }
 }
Beispiel #4
0
 public void switchToPopup() {
   WebLocator popup = new WebLocator().setClasses("popup");
   WebLocator iframe = new WebLocator(popup).setTag("iframe");
   iframe.assertReady();
   WebDriverConfig.getDriver().switchTo().frame(iframe.currentElement);
 }