Java 类org.openqa.selenium.support.ui.FluentWait 实例源码

项目:easycukes    文件:SeleniumHelper.java   
/**
 * @param by
 * @return
 */
public static void waitUntilValueIsSelected(@NonNull final WebDriver driver,
                                            @NonNull final By by, @NonNull final String value) {
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);
    wait.until(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver webDriver) {
            try {
                final WebElement webElement = webDriver.findElement(by);
                new Select(webElement).selectByValue(value);
                return webElement.getAttribute("value").equals(value);
            } catch (final StaleElementReferenceException e) {
                return false;
            }
        }
    });
}
项目:POM_HYBRID_FRAMEOWRK    文件:WebUtilities.java   
/**
 * Wait for element to appear.
 *
 * @param driver the driver
 * @param element the element
 * @param logger the logger
 */
public static boolean waitForElementToAppear(WebDriver driver, WebElement element, ExtentTest logger) {
    boolean webElementPresence = false;
    try {
        Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver).pollingEvery(2, TimeUnit.SECONDS)
                .withTimeout(60, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
        fluentWait.until(ExpectedConditions.visibilityOf(element));
        if (element.isDisplayed()) {
            webElementPresence= true;
        }
    } catch (TimeoutException toe) {
        logger.log(LogStatus.ERROR, "Timeout waiting for webelement to be present<br></br>" + toe.getStackTrace());
    } catch (Exception e) {
        logger.log(LogStatus.ERROR, "Exception occured<br></br>" + e.getStackTrace());
    }
    return webElementPresence;
}
项目:WebAutomation_AllureParallel    文件:FluentWaiting.java   
public static void waitUntillElementToBeClickable(int TotalTimeInSeconds, int PollingTimeInMilliseconds, WebElement Element)
{
     FluentWait<WebDriver> ClickableWait = new FluentWait<WebDriver>(getWebDriver())
                .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
                .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
                .ignoring(NoSuchElementException.class);

     ClickableWait.until(ExpectedConditions.elementToBeClickable(Element));
}
项目:Quantum    文件:AppiumUtils.java   
private static MobileElement fluentWait(AppiumDriver driver, By xpath) {
    MobileElement waitElement = null;

    FluentWait<RemoteWebDriver> fwait = new FluentWait<RemoteWebDriver>(driver).withTimeout(15, TimeUnit.SECONDS)
            .pollingEvery(500, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class)
            .ignoring(TimeoutException.class);

    try {
        waitElement = (MobileElement) fwait.until(new Function<RemoteWebDriver, WebElement>() {
            public WebElement apply(RemoteWebDriver driver) {
                return driver.findElement(xpath);
            }
        });
    } catch (Exception e) {
    }
    return waitElement;
}
项目:menggeqa    文件:AppiumElementLocator.java   
private List<WebElement> waitFor() {
    // When we use complex By strategies (like ChainedBy or ByAll)
    // there are some problems (StaleElementReferenceException, implicitly
    // wait time out
    // for each chain By section, etc)
    try {
        changeImplicitlyWaitTimeOut(0, TimeUnit.SECONDS);
        FluentWait<By> wait = new FluentWait<>(by);
        wait.withTimeout(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
        return wait.until(waitingFunction);
    } catch (TimeoutException e) {
        return new ArrayList<>();
    } finally {
        changeImplicitlyWaitTimeOut(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
    }
}
项目:che    文件:TestWebElementRenderChecker.java   
private void waitElementIsStatic(FluentWait<WebDriver> webDriverWait, WebElement webElement) {
  AtomicInteger sizeHashCode = new AtomicInteger();

  webDriverWait.until(
      (ExpectedCondition<Boolean>)
          driver -> {
            Dimension newDimension = waitAndGetWebElement(webElement).getSize();

            if (dimensionsAreEquivalent(sizeHashCode, newDimension)) {
              return true;
            } else {
              sizeHashCode.set(getSizeHashCode(newDimension));
              return false;
            }
          });
}
项目:NYU-Bobst-Library-Reservation-Automator-Java    文件:RunAutomator.java   
/**
 * The wrapper for the actual run automator
 * @param browser The current browser for this run
 * @param user The current user for this run
 * @param offset The current amount of offsets (occurs when a time is already selected, but user is good)
 * @param setup The current setup containing all settings, loggers, and user pools
 * @throws CompletedException
 * @throws TimeSlotTakenException
 * @throws InterruptedException
 * @throws UserNumberException
 * @throws ReservationException
 * @throws InvalidLoginException
 */
public static void run(WebDriver browser, User user, int offset, Setup setup)
        throws CompletedException, TimeSlotTakenException, InterruptedException, UserNumberException,
        ReservationException, InvalidLoginException, NotConnectedException
{
    // Defines the wait
    FluentWait<WebDriver> wait = new FluentWait<>(browser)
            .withTimeout(20, TimeUnit.SECONDS)
            .pollingEvery(500, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);

    // Steps through each run component
    initiate(browser, wait);
    login(browser, user);
    setDate(browser, wait, setup.getSettings());
    TimeTuple timeTuple = setTime(browser, offset, setup.getUserPool(), setup.getSettings());
    selectRoom(browser, user, wait, setup.getSettings());
    updateLog(user, setup.getUserPool(), timeTuple);
}
项目:redsniff    文件:RedsniffWebDriverTester.java   
/**
    * Wait until the supplied {@link FindingExpectation} becomes satisfied, or throw a {@link TimeoutException}
    * , using the supplied {@link FluentWait} 
    * This should only be done using a wait obtained by calling {@link #waiting()} to ensure the correct arguments are passed.
    * 
    * @param expectation
    * @param wait
    * @return
    */
public <T, E, Q extends TypedQuantity<E, T>> T waitFor(
         final FindingExpectation<E, Q, SearchContext> expectation, FluentWait<WebDriver> wait) {
    try {
        return new Waiter(wait).waitFor(expectation);
    }
    catch(FindingExpectationTimeoutException e){
        //do a final check to get the message unoptimized
        ExpectationCheckResult<E, Q> resultOfChecking = checker.resultOfChecking(expectation);
        String reason;
        if(resultOfChecking.meetsExpectation())
            reason = "Expectation met only just after timeout.  At timeout was:\n" + e.getReason();
        else {
            reason = resultOfChecking.toString();
            //if still not found first check there isn't a page error or something
            defaultingChecker().assertNoUltimateCauseWhile(newDescription().appendText("expecting ").appendDescriptionOf(expectation));
        }
        throw new FindingExpectationTimeoutException(e.getOriginalMessage(), reason, e);
    }
}
项目:easycukes    文件:SeleniumHelper.java   
/**
 * @param driver
 * @param by
 * @return
 */
public static WebElement waitForElementToBePresent(@NonNull final WebDriver driver,
                                                   @NonNull final By by) {
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);
    return wait.until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver webDriver) {
            try {
                if (webDriver.findElement(by).isDisplayed())
                    return webDriver.findElement(by);
                return null;
            } catch (final ElementNotVisibleException e) {
                return null;
            }
        }
    });
}
项目:easycukes    文件:SeleniumHelper.java   
/**
 * @param text
 */
public static void waitUntilTextIsSelected(@NonNull final WebDriver driver,
                                           @NonNull final By by, @NonNull final String text) {
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);

    wait.until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver webDriver) {
            final WebElement webElement = webDriver.findElement(by);
            new Select(webElement).selectByVisibleText(text);
            return webElement;
        }
    });
}
项目:Testy    文件:WebLocatorDriverExecutor.java   
private WebElement doWaitElement(final WebLocator el, final long millis) {
    Wait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(millis, TimeUnit.MILLISECONDS)
            .pollingEvery(1, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class)
            .ignoring(ElementNotVisibleException.class)
            .ignoring(WebDriverException.class);

    try {
        if (el.getPathBuilder().isVisibility()) {
            el.currentElement = wait.until(ExpectedConditions.visibilityOfElementLocated(el.getSelector()));
        } else {
            el.currentElement = wait.until(d -> d.findElement(el.getSelector()));
        }
    } catch (TimeoutException e) {
        el.currentElement = null;
    }
    return el.currentElement;
}
项目:carina    文件:ToastDetector.java   
private void waitForToast() {
    LOGGER.info("Wait for toast...");
    isPresent = false;
    FluentWait<WebDriver> fluentWait = new FluentWait<>(webDriver);
    fluentWait.withTimeout(waitTimeout, TimeUnit.SECONDS).pollingEvery(300, TimeUnit.MILLISECONDS).until(new Function<WebDriver, Boolean>() {
        @Override
        public Boolean apply(WebDriver input) {
            List<?> webElemenList = webDriver.findElements(By.xpath(String.format(TOAST_PATTERN, toastToWait)));
            if (webElemenList.size() == 1) {
                LOGGER.info("Toast with text present: " + toastToWait);
                isPresent = true;
                return true;
            } else {
                return false;
            }
        }
    });
}
项目:carina    文件:ExtendedWebElement.java   
/**
 * is Element Not Present After Wait
 *
 * @param timeout in seconds
 * @return boolean - false if element still present after wait - otherwise true if it disappear
 */
public boolean isElementNotPresentAfterWait(final long timeout) {
    final ExtendedWebElement element = this;

    LOGGER.info(String.format("Check element %s not presence after wait.", element.getName()));

    Wait<WebDriver> wait =
            new FluentWait<WebDriver>(getDriver()).withTimeout(timeout, TimeUnit.SECONDS).pollingEvery(1,
                    TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
    try {
        return wait.until(driver -> {
            boolean result = driver.findElements(element.getBy()).isEmpty();
            if (!result) {
                LOGGER.info(String.format("Element '%s' is still present. Wait until it disappear.", element
                        .getNameWithLocator()));
            }
            return result;
        });
    } catch (Exception e) {
        LOGGER.error("Error happened: " + e.getMessage(), e.getCause());
        LOGGER.warn("Return standard element not presence method");
        return !element.isElementPresent();
    }
}
项目:jwala    文件:JwalaUi.java   
public void testForBusyIcon(final int showTimeout, final int hideTimeout) {
    new FluentWait(driver).withTimeout(showTimeout, TimeUnit.SECONDS).pollingEvery(100, TimeUnit.MILLISECONDS)
            .until(ExpectedConditions.numberOfElementsToBe(
                    By.xpath("//div[contains(@class, 'AppBusyScreen') and contains(@class, 'show')]"), 1));
    // Please take note that when "display none" is re-inserted, the whitespace in between the attribute and the value is not there anymore e.g.
    // display: none => display:none hence the xpath => contains(@style,'display:none')
    new WebDriverWait(driver, hideTimeout)
            .until(ExpectedConditions.numberOfElementsToBe(
                    By.xpath("//div[contains(@class, 'AppBusyScreen') and contains(@class, 'show')]"), 0));
}
项目:POM_HYBRID_FRAMEOWRK    文件:WebUtilities.java   
/**
 * Wait for element to disappear.
 *
 * @param driver the driver
 * @param element the element
 * @param logger the logger
 * @return true, if successful
 */
public static boolean waitForElementToDisappear(WebDriver driver, WebElement element, ExtentTest logger) {
    try {
        Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver).withTimeout(60, TimeUnit.SECONDS)
                .pollingEvery(2, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);

        fluentWait.until(ExpectedConditions.invisibilityOf(element));
        return true;
    } catch (Exception e) {
        logger.log(LogStatus.ERROR,
                "Error occured while waiting for element to disappear</br>" + e.getStackTrace());
        return false;
    }
}
项目:POM_HYBRID_FRAMEOWRK    文件:WebUtilities.java   
/**
 * Wait for element staleness.
 *
 * @param driver the driver
 * @param element the element
 * @return true, if successful
 */
public static boolean waitForElementStaleness(WebDriver driver, WebElement element) {
    boolean staleStatus = new FluentWait<WebDriver>(driver)
            .withTimeout(60, TimeUnit.SECONDS)
            .pollingEvery(5, TimeUnit.SECONDS)
            .until(ExpectedConditions.stalenessOf(element));

    return staleStatus;
}
项目:WebAutomation_AllureParallel    文件:FluentWaiting.java   
public static void waitUntillElementToBeSelected(int TotalTimeInSeconds, int PollingTimeInMilliseconds, WebElement Element)
{
     FluentWait<WebDriver> SelectableWait = new FluentWait<WebDriver>(getWebDriver())
                .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
                .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
                .ignoring(NoSuchElementException.class);

     SelectableWait.until(ExpectedConditions.elementToBeSelected(Element));
}
项目:WebAutomation_AllureParallel    文件:FluentWaiting.java   
public static void waitUntillElementToBeVisible(int TotalTimeInSeconds, int PollingTimeInMilliseconds, WebElement Element)
{
     FluentWait<WebDriver> visibleWait = new FluentWait<WebDriver>(getWebDriver())
                .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
                .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
                .ignoring(NoSuchElementException.class);

     visibleWait.until(ExpectedConditions.visibilityOf(Element));
}
项目:WebAutomation_AllureParallel    文件:FluentWaiting.java   
public static void waitUntillAlertWindowsPopUp(int TotalTimeInSeconds, int PollingTimeInMilliseconds)
{
     FluentWait<WebDriver> alertWait = new FluentWait<WebDriver>(getWebDriver())
                .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
                .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
                .ignoring(NoSuchElementException.class);

     alertWait.until(ExpectedConditions.alertIsPresent());
}
项目:WebAutomation_AllureParallel    文件:FluentWaiting.java   
public static void waitUntillVisibilityOfElements(int TotalTimeInSeconds, int PollingTimeInMilliseconds, List<WebElement> Elements)
{
     FluentWait<WebDriver> visibleWait = new FluentWait<WebDriver>(getWebDriver())
                .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
                .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
                .ignoring(NoSuchElementException.class);

     visibleWait.until(ExpectedConditions.visibilityOfAllElements(Elements));
}
项目:WebAutomation_AllureParallel    文件:FluentWaiting.java   
public static void waitForTitleToBe(int TotalTimeInSeconds, int PollingTimeInMilliseconds, String PageTitle)
{
     FluentWait<WebDriver> titleWait = new FluentWait<WebDriver>(getWebDriver())
                .withTimeout(TotalTimeInSeconds, TimeUnit.SECONDS)
                .pollingEvery(PollingTimeInMilliseconds, TimeUnit.MILLISECONDS)
                .ignoring(NoSuchElementException.class);

     titleWait.until(ExpectedConditions.titleContains(PageTitle));
}
项目:qa-automation    文件:WebDriverUtils.java   
public static void waitForElementPresent(WebDriver driver, WebElement element){
    Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
            .withTimeout(60, SECONDS)
            .pollingEvery(5, SECONDS)
            .ignoring(NoSuchElementException.class);
    wait.until(ExpectedConditions.visibilityOf(element));
}
项目:aet    文件:WaitForHelper.java   
/**
 * This helper method allows a Selenium WebDriver to wait until one or more ExpectedConditions are
 * met. The WebDriver waits for each ExpectedCondition to be met in a sequence, probing the page
 * every 500ms until the ExpectedCondition is met or the timeout limit is reached.
 *
 * @param webDriver The instance of a WebDriver navigating the page under test
 * @param timeoutInSeconds The time after which waiting ends unless the ExpectedCondition is met
 * earlier.
 * @param expectedConditions One or more of ExpectedConditions that have to be met.
 */
public static CollectorStepResult waitForExpectedCondition(
    WebDriver webDriver,
    long timeoutInSeconds,
    ExpectedCondition<?>... expectedConditions) {
  FluentWait<WebDriver> wait = new FluentWait<>(webDriver).withTimeout(timeoutInSeconds,
      TimeUnit.SECONDS).pollingEvery(500, TimeUnit.MILLISECONDS)
      .ignoring(NoSuchElementException.class, StaleElementReferenceException.class);

  for (ExpectedCondition<?> expectedCondition : expectedConditions) {

    wait.until(expectedCondition);
  }
  return CollectorStepResult.newModifierResult();
}
项目:gridmize    文件:BaseCell.java   
public void click() {
        By bySelector = By.cssSelector(getFormatedSelector());
        new FluentWait<WebDriver>(getDriver())
                .withTimeout(5, TimeUnit.SECONDS)
                .pollingEvery(100, TimeUnit.MILLISECONDS)
                .ignoring(NoSuchElementException.class)
                .until(ExpectedConditions.elementToBeClickable(bySelector))
                .click();
        waitScreenLoader();
}
项目:gridmize    文件:BaseCell.java   
private void waitElementClose(String Css, int timeout) {
    new FluentWait<WebDriver>(getDriver())
            .withTimeout(100, TimeUnit.SECONDS)
            .pollingEvery(100, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class)
            .until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(Css)));
}
项目:brixen    文件:WaitForElementVisible.java   
/**
 * Polls the specified {@code WebElement} at the specified polling interval until it becomes visible or the
 * polling timeout expires.
 *
 * @param element           the {@code WebElement} that is expected to become visible
 * @param pollingTimeout    the polling timeout in seconds to poll the {@code WebElement} for visibility status
 * @param pollingInterval   the polling interval in seconds between checks for the visibility status of the
 *                          {@code WebElement}
 */
public void accept(WebElement element, Integer pollingTimeout, Integer pollingInterval) {
    new FluentWait<>(element)
            .withTimeout(pollingTimeout, TimeUnit.SECONDS)
            .pollingEvery(pollingInterval, TimeUnit.SECONDS)
            .until((WebElement element1) -> {
                try {
                    return element1.isDisplayed();
                } catch(NoSuchElementException | StaleElementReferenceException e) {
                    return false;
                }
            });
}
项目:brixen    文件:WaitForAlertNotPresent.java   
public void accept(final WebDriver driver, final Integer pollingTimeoutInSeconds, final Integer
        pollingIntervalInSeconds) {
    new FluentWait<>(driver)
            .withTimeout(pollingTimeoutInSeconds, TimeUnit.SECONDS)
            .pollingEvery(pollingIntervalInSeconds, TimeUnit.SECONDS)
            .until((WebDriver driver1) -> !(new IsAlertPresent().test(driver1)));
}
项目:brixen    文件:WaitForJQueryToComplete.java   
public void accept(final WebDriver driver, final Integer pollingTimeoutInSeconds, final Integer
        pollingIntervalInSeconds) {
    new FluentWait<>(driver)
            .withTimeout(pollingTimeoutInSeconds, TimeUnit.SECONDS)
            .pollingEvery(pollingIntervalInSeconds, TimeUnit.SECONDS)
            .until((WebDriver driver1) -> {
        return new IsJQueryComplete().test(driver1);
    });
}
项目:brixen    文件:WaitForElementNotVisible.java   
/**
 * Polls the specified {@code WebElement} at the specified polling interval until it becomes invisible or the
 * polling timeout expires.
 *
 * @param element           the {@code WebElement} that is expected to become invisible
 * @param pollingTimeout    the polling timeout in seconds to poll the {@code WebElement} for visibility status
 * @param pollingInterval   the polling interval in seconds between checks for the visibility status of the
 *                          {@code WebElement}
 */
public void accept(WebElement element, Integer pollingTimeout, Integer pollingInterval) {
    new FluentWait<>(element)
            .withTimeout(pollingTimeout, TimeUnit.SECONDS)
            .pollingEvery(pollingInterval, TimeUnit.SECONDS)
            .until((WebElement element1) -> {
                try {
                    return element1.isDisplayed();
                } catch(NoSuchElementException | StaleElementReferenceException e) {
                    return true;
                }
            });
}
项目:de.lgohlke.selenium-webdriver    文件:ErrorLoggingWebDriverEventListener.java   
private boolean isExceptionFromFluentWait(Throwable throwable) {
    if (!(throwable instanceof NoSuchElementException)) {
        return false;
    }

    for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
        if (FluentWait.class.getName().equals(stackTraceElement.getClassName())) {
            return true;
        }
    }
    return false;
}
项目:che    文件:CodenvyEditor.java   
private void waitJavaDocPopupSrcAttributeIsNotEmpty() {
  new FluentWait<>(seleniumWebDriver)
      .withTimeout(LOAD_PAGE_TIMEOUT_SEC * 2, SECONDS)
      .pollingEvery(LOAD_PAGE_TIMEOUT_SEC / 2, SECONDS)
      .ignoring(StaleElementReferenceException.class, NoSuchElementException.class)
      .until(ExpectedConditions.attributeToBeNotEmpty(autocompleteProposalJavaDocPopup, "src"));
}
项目:che    文件:CodenvyEditor.java   
private String getElementSrcLink(WebElement element) {
  FluentWait<WebDriver> srcLinkWait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(LOAD_PAGE_TIMEOUT_SEC, SECONDS)
          .pollingEvery(500, MILLISECONDS)
          .ignoring(StaleElementReferenceException.class, NoSuchElementException.class);

  return srcLinkWait.until((ExpectedCondition<String>) driver -> element.getAttribute("src"));
}
项目:che    文件:OrganizationListPage.java   
private void waitForElementDisappearance(String xpath) {
  FluentWait<SeleniumWebDriver> wait =
      new FluentWait<>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  wait.until(
      (Function<WebDriver, Boolean>)
          driver -> {
            List<WebElement> elements = seleniumWebDriver.findElements(By.xpath(xpath));
            return elements.isEmpty() || !elements.get(0).isDisplayed();
          });
}
项目:che    文件:AddMember.java   
private void waitForElementDisappearance(String xpath) {
  FluentWait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  wait.until(
      (Function<WebDriver, Boolean>)
          driver -> {
            List<WebElement> elements = seleniumWebDriver.findElements(By.xpath(xpath));
            return elements.isEmpty() || elements.get(0).isDisplayed();
          });
}
项目:che    文件:AddMember.java   
/**
 * Wait for popup is attached to DOM and animation ends.
 *
 * @param xpath xpath to match the 'che-popup' element
 */
private void waitForPopupAppearence(String xpath) {
  FluentWait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  Map<String, Integer> lastSize = new HashMap<>();
  lastSize.put("height", 0);
  lastSize.put("width", 0);

  wait.until(
      (Function<WebDriver, Boolean>)
          driver -> {
            List<WebElement> elements = seleniumWebDriver.findElements(By.xpath(xpath));
            if (elements.isEmpty()) {
              return false;
            }

            Dimension size = elements.get(0).getSize();
            if (lastSize.get("height") < size.getHeight()
                || lastSize.get("width") < size.getHeight()) {
              lastSize.put("height", size.getHeight());
              lastSize.put("width", size.getWidth());

              return false;
            }

            return true;
          });
}
项目:che    文件:PullRequestPanel.java   
public void openPullRequestOnGitHub() {
  Wait<WebDriver> wait =
      new FluentWait(seleniumWebDriver)
          .withTimeout(ATTACHING_ELEM_TO_DOM_SEC, SECONDS)
          .pollingEvery(500, MILLISECONDS)
          .ignoring(WebDriverException.class);
  wait.until(visibilityOfElementLocated(By.xpath(PullRequestLocators.OPEN_GITHUB_BTN))).click();
}
项目:che    文件:Consoles.java   
public void openServersTabFromContextMenu(String machineName) {
  Wait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(ELEMENT_TIMEOUT_SEC, SECONDS)
          .pollingEvery(500, MILLISECONDS)
          .ignoring(WebDriverException.class);

  WebElement machine =
      wait.until(visibilityOfElementLocated(By.xpath(format(MACHINE_NAME, machineName))));
  wait.until(visibilityOf(machine)).click();

  actionsFactory.createAction(seleniumWebDriver).moveToElement(machine).contextClick().perform();
  redrawDriverWait.until(visibilityOf(serversMenuItem)).click();
}
项目:che    文件:CommandsToolbar.java   
/** wait appearance of process timer on commands toolbar and try to get value of the timer */
public String getTimerValue() {
  Wait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(REDRAW_UI_ELEMENTS_TIMEOUT_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(StaleElementReferenceException.class);

  return wait.until(driver -> driver.findElement(By.id(Locators.TIMER_LOCATOR)).getText());
}
项目:che    文件:Swagger.java   
/** expand 'workspace' item */
private void expandWorkSpaceItem() {
  Wait fluentWait =
      new FluentWait(seleniumWebDriver)
          .withTimeout(LOAD_PAGE_TIMEOUT_SEC, SECONDS)
          .pollingEvery(MINIMUM_SEC, SECONDS)
          .ignoring(StaleElementReferenceException.class, NoSuchElementException.class);
  fluentWait.until((ExpectedCondition<Boolean>) input -> workSpaceLink.isEnabled());
  workSpaceLink.click();
}
项目:che    文件:JavaTestRunnerPluginConsole.java   
/**
 * Wait single method in the result tree marked as failed (red color).
 *
 * @param nameOfFailedMethods name of that should fail
 */
public void waitMethodMarkedAsFailed(String nameOfFailedMethods) {
  FluentWait<WebDriver> wait =
      new FluentWait<WebDriver>(seleniumWebDriver)
          .withTimeout(ATTACHING_ELEM_TO_DOM_SEC, TimeUnit.SECONDS)
          .pollingEvery(200, TimeUnit.MILLISECONDS)
          .ignoring(NotFoundException.class, StaleElementReferenceException.class);
  String xpathToExpectedMethod = "//span[@id='%s']/following-sibling::*/div[text()='%s']";
  wait.until(
      ExpectedConditions.visibilityOfElementLocated(
          By.xpath(
              String.format(
                  xpathToExpectedMethod, METHODS_MARKED_AS_FAILED, nameOfFailedMethods))));
}