Esempio n. 1
0
  /**
   * Waits until the specified JavaScript returns a non-false value.
   *
   * @param expression the JavaScript expression to evaluate
   * @param timeout time in seconds to wait until a TimeoutException is thrown
   * @throws TimeoutException
   */
  public void evaluatedJavaScriptExpression(String expression, int timeout)
      throws TimeoutException {
    WebDriverWait wait = new WebDriverWait(browser.getWebDriver(), timeout);

    // start waiting for adequate evaluation of expression
    wait.until(new JavaScriptEvaluatedWaitCondition(browser, expression));
  }
Esempio n. 2
0
  /**
   * Waits until element contains the specified text. Useful for waiting for an AJAX call to
   * complete.
   *
   * @param element the element to observe
   * @param text when the element contains this text the execution of the program will be continued
   * @throws TimeoutException
   */
  public void elementText(HtmlElement element, String text) throws TimeoutException {
    FluentWait<WebDriver> wait =
        new FluentWait<WebDriver>(browser.getWebDriver())
            .withTimeout(timeout, TimeUnit.SECONDS)
            .pollingEvery(500, TimeUnit.MILLISECONDS);

    // start waiting for given text of element
    wait.until(new ElementHasTextWaitCondition(element, text));
  }
Esempio n. 3
0
  /**
   * Waits until element is found. Useful for waiting for an AJAX call to complete.
   *
   * @param query the element query
   * @throws TimeoutException
   */
  public void query(HtmlQuery query) throws TimeoutException {
    //		WebDriverWait wait = new WebDriverWait(browser.getWebDriver(), timeout);
    FluentWait<WebDriver> wait =
        new FluentWait<WebDriver>(browser.getWebDriver())
            .withTimeout(timeout, TimeUnit.SECONDS)
            .pollingEvery(1, TimeUnit.SECONDS);

    // start waiting for given element
    wait.until(new ElementWaitCondition(query));
  }
Esempio n. 4
0
 @Override
 protected void parseTitle() {
   title = browser.getWebDriver().getTitle();
   //		browser.log().debug(" TITLE: " + content.getTitle());
 }
Esempio n. 5
0
 public HtmlParser(Browser browser) {
   super(browser.getWebDriver().getPageSource());
   this.browser = browser;
 }