예제 #1
0
 public ContactsPage() {
   wait = DriverManager.getInstance().getWait();
   driver = DriverManager.getInstance().getDriver();
   PageFactory.initElements(driver, this);
   try {
     wait.withTimeout(3, TimeUnit.SECONDS).until(ExpectedConditions.visibilityOf(contactsTitle));
   } catch (WebDriverException e) {
     throw new WebDriverException(e);
   } finally {
     wait.withTimeout(15, TimeUnit.SECONDS);
   }
 }
예제 #2
0
 public OpportunitiesPage() {
   wait = DriverManager.getInstance().getWait();
   driver = DriverManager.getInstance().getDriver();
   PageFactory.initElements(driver, this);
   try {
     wait.withTimeout(TIMEOUT_MIN, TimeUnit.SECONDS)
         .until(ExpectedConditions.visibilityOf(opportunitiesTitle));
   } catch (WebDriverException e) {
     throw new WebDriverException(e);
   } finally {
     wait.withTimeout(TIMEOUT_NORMAL, TimeUnit.SECONDS);
   }
 }
예제 #3
0
  @Test
  public void myFirstGoogleTest() {
    driver.get("http://www.google.com");

    ((WebDriverWait) wait).withTimeout(60, TimeUnit.SECONDS);

    WebElement searchBox = driver.findElement(By.name("q"));
    searchBox.sendKeys("Cheese");

    WebElement navend = wait.until(navEndIsVisibleAndTitleContains("heese"));
  }
예제 #4
0
 private WebElement doWaitElement(final WebLocator el, final long millis) {
   WebDriverWait wait = new WebDriverWait(driver, 0, 100);
   wait.withTimeout(
       millis,
       TimeUnit.MILLISECONDS); // hack enforce WebDriverWait to accept millis (default is seconds)
   try {
     if (el.getPathBuilder().isVisibility()) {
       el.currentElement =
           wait.until(ExpectedConditions.visibilityOfElementLocated(el.getSelector()));
     } else {
       el.currentElement =
           wait.until(
               new ExpectedCondition<WebElement>() {
                 public WebElement apply(WebDriver driver1) {
                   return driver.findElement(el.getSelector());
                 }
               });
     }
   } catch (TimeoutException e) {
     el.currentElement = null;
   }
   return el.currentElement;
 }