List of usage examples for org.openqa.selenium.support.ui FluentWait FluentWait
public FluentWait(T input)
From source file:org.alfresco.po.PageElement.java
License:Open Source License
/** * Helper method to find a {@link WebElement} with a time limit in milliseconds. During the wait period it will check for the element every 100 millisecond. * //from w w w . j av a 2 s . c o m * @param by {@link By} criteria to search by * @param limit time limit * @param interval polling frequency * @return {@link WebElement} HTML element */ public WebElement findAndWaitInNestedElement(final By by, final long limit, final long interval) { FluentWait<By> fluentWait = new FluentWait<By>(by); fluentWait.pollingEvery(interval, TimeUnit.MILLISECONDS); fluentWait.withTimeout(limit, TimeUnit.MILLISECONDS); fluentWait.until(new Predicate<By>() { public boolean apply(By by) { try { return getWrappedElement().findElement(by).isDisplayed(); } catch (NoSuchElementException ex) { return false; } } }); return getWrappedElement().findElement(by); }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
/** * Helper method to find a {@link WebElement} with a time limit in * milliseconds. During the wait period it will check for the element every * 100 millisecond. If the element is not displayed, refresh the page. * * @param by {@link By} criteria to search by * @return {@link WebElement}// w w w .j av a2 s . c o m */ public WebElement findAndWaitWithRefresh(final By by, final long limit) { if (null == by) { throw new IllegalArgumentException("A search By criteria is required"); } FluentWait<By> fluentWait = new FluentWait<By>(by); fluentWait.pollingEvery(100, TimeUnit.MILLISECONDS); fluentWait.withTimeout(limit, TimeUnit.MILLISECONDS); fluentWait.ignoring(NoSuchElementException.class); fluentWait.until(new Predicate<By>() { public boolean apply(By by) { try { return driver.findElement(by).isDisplayed(); } catch (NoSuchElementException ex) { driver.navigate().refresh(); return false; } } }); return driver.findElement(by); }
From source file:org.apache.zeppelin.AbstractZeppelinIT.java
License:Apache License
protected WebElement pollingWait(final By locator, final long timeWait) { Wait<WebDriver> wait = new FluentWait<>(driver).withTimeout(timeWait, TimeUnit.SECONDS) .pollingEvery(1, TimeUnit.SECONDS).ignoring(NoSuchElementException.class); return wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver driver) { return driver.findElement(locator); }//from ww w.j ava2 s. c o m }); }
From source file:org.bigtester.ate.model.page.elementfind.AbstractElementFind.java
License:Apache License
/** * Creates the wait.//from w ww . ja va 2s.c om * * @param driver * the driver */ public void createWait(WebDriver driver) { wait = new FluentWait<WebDriver>(driver).withTimeout(30, TimeUnit.SECONDS).pollingEvery(5, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class); }
From source file:org.eclipse.che.selenium.pageobject.dashboard.organization.AddMember.java
License:Open Source License
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(); });/*from ww w. j a v a 2s. co m*/ }
From source file:org.eclipse.che.selenium.pageobject.dashboard.organization.AddMember.java
License:Open Source License
/** * Wait for popup is attached to DOM and animation ends. * * @param xpath xpath to match the 'che-popup' element *///from ww w .j a v a 2 s. com 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; }); }
From source file:org.eclipse.che.selenium.pageobject.dashboard.organization.OrganizationListPage.java
License:Open Source License
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(); });/*from w ww . ja v a 2 s. c o m*/ }
From source file:org.eclipse.che.selenium.pageobject.intelligent.CommandsToolbar.java
License:Open Source License
/** 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()); }
From source file:org.eclipse.che.selenium.pageobject.PullRequestPanel.java
License:Open Source License
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(); }
From source file:org.eclipse.che.selenium.pageobject.Swagger.java
License:Open Source License
/** expand 'workspace' item */ private void expandWorkSpaceItem() { Wait fluentWait = new FluentWait(seleniumWebDriver).withTimeout(ELEMENT_TIMEOUT_SEC, SECONDS) .pollingEvery(MINIMUM_SEC, SECONDS) .ignoring(StaleElementReferenceException.class, NoSuchElementException.class); fluentWait.until((ExpectedCondition<Boolean>) input -> workSpaceLink.isEnabled()); workSpaceLink.click();/*from www. j a v a 2s . c o m*/ }