コード例 #1
0
  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;
  }
コード例 #2
0
 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);
   }
 }
コード例 #3
0
ファイル: CardView.java プロジェクト: nmatei/pay-invoices
 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();
   }
 }
コード例 #4
0
ファイル: CardView.java プロジェクト: nmatei/pay-invoices
 public void switchToPopup() {
   WebLocator popup = new WebLocator().setClasses("popup");
   WebLocator iframe = new WebLocator(popup).setTag("iframe");
   iframe.assertReady();
   WebDriverConfig.getDriver().switchTo().frame(iframe.currentElement);
 }