예제 #1
0
  /**
   * First, verify that window.$A has been installed. Then, wait until {@link
   * #isAuraFrameworkReady()} returns true. We assume the document has finished loading at this
   * point: callers should have previously called {@link #waitForDocumentReady()}.
   */
  public void waitForAuraFrameworkReady(final Set<String> expectedErrors) {
    String doNotAssign =
        "\nThis message means, you aren't even on Aura application at this point. "
            + "Please do not assign this test failure to Aura team/s unless, Aura team/s is the owner of this test. ";
    WebDriverWait waitAuraPresent = new WebDriverWait(driver, timeoutInSecs);
    waitAuraPresent
        .withMessage("Initialization error: Perhaps the initial GET failed." + doNotAssign)
        .until(
            new Function<WebDriver, Boolean>() {
              @Override
              public Boolean apply(WebDriver input) {
                return (Boolean) getRawEval("return !!window.$A");
              }
            });

    WebDriverWait waitFinishedInit = new WebDriverWait(driver, timeoutInSecs);
    waitFinishedInit
        .ignoring(StaleElementReferenceException.class)
        .withMessage("Initialization error: $A present but failed to initialize")
        .until(
            new Function<WebDriver, Boolean>() {
              @Override
              public Boolean apply(WebDriver input) {
                assertNoAuraErrorMessage(expectedErrors);
                return isAuraFrameworkReady();
              }
            });
  }
예제 #2
0
 /**
  * Waits for element with matching locator to appear in dom.
  *
  * <p>This will wait for at least one element with the locator to appear in the dom, and it will
  * return the first element found. If there are more than one element that match the locator, this
  * will succeed when the first one appears.
  *
  * @param msg Error message on timeout.
  * @param locator By of element waiting for.
  */
 public WebElement waitForElement(String msg, By locator) {
   WaitAndRetrieve war = new WaitAndRetrieve(locator);
   WebDriverWait wait = new WebDriverWait(driver, timeoutInSecs);
   wait.withMessage(msg);
   wait.ignoring(NoSuchElementException.class);
   wait.until(war);
   return war.getFound();
 }