List of usage examples for org.openqa.selenium.support.ui FluentWait FluentWait
public FluentWait(T input)
From source file:com.linagora.obm.ui.page.CreateCalendarPage.java
License:Open Source License
public CalendarPage createEvent(UIEvent eventToCreate) { doCreateEvent(eventToCreate);// ww w .j a va 2 s .co m new FluentWait<WebDriver>(driver).until(new Predicate<WebDriver>() { @Override public boolean apply(WebDriver input) { return calendarHeader.isDisplayed(); } }); return pageFactory.create(driver, CalendarPage.class); }
From source file:com.linagora.obm.ui.page.CreateCalendarPage.java
License:Open Source License
public CalendarPage createEventFails(UIEvent eventToCreate) { doCreateEvent(eventToCreate);//from w w w .j av a 2s. c o m new FluentWait<WebDriver>(driver).until(new Predicate<WebDriver>() { @Override public boolean apply(WebDriver input) { return !elMessagesError().isEmpty(); } }); return pageFactory.create(driver, CalendarPage.class); }
From source file:com.linagora.obm.ui.page.CreateCalendarPage.java
License:Open Source License
public CalendarPage createEventThrowingAlert(UIEvent eventToCreate) { doCreateEvent(eventToCreate);// ww w. j a va2 s.c o m new FluentWait<WebDriver>(driver).until(new Predicate<WebDriver>() { @Override public boolean apply(WebDriver input) { Alert alert = driver.switchTo().alert(); if (alert != null) { return true; } return false; } }); return pageFactory.create(driver, CalendarPage.class); }
From source file:com.linagora.obm.ui.page.CreateContactPage.java
License:Open Source License
private void managePopup(final boolean accept) { new FluentWait<WebDriver>(driver).until(new Predicate<WebDriver>() { @Override/* w w w . j a va 2 s . co m*/ public boolean apply(WebDriver input) { Alert alert = driver.switchTo().alert(); if (alert != null) { if (accept) { alert.accept(); } else { alert.dismiss(); } return true; } return false; } }); }
From source file:com.linagora.obm.ui.page.CreateContactPage.java
License:Open Source License
private ContactPage createContactPage() { new FluentWait<WebDriver>(driver).withTimeout(2, TimeUnit.SECONDS).until(new Predicate<WebDriver>() { @Override/* w w w . j a v a2s. co m*/ public boolean apply(WebDriver input) { return !informationGrid.isDisplayed() && "expanded".equals(dataGrid.getAttribute("class")); } }); return pageFactory.create(driver, ContactPage.class); }
From source file:com.linagora.obm.ui.page.CreateContactPage.java
License:Open Source License
public CreateContactPage createContactAsExpectingError(UIContact contactToCreate) { doCreateContact(contactToCreate);/*from w ww . ja v a2 s.c o m*/ new FluentWait<WebDriver>(driver).until(new Predicate<WebDriver>() { @Override public boolean apply(WebDriver input) { return lastname.getAttribute("class").equalsIgnoreCase("error"); } }); return this; }
From source file:com.mengge.pagefactory.AppiumElementLocator.java
License:Apache License
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 {//from ww w. j a va 2 s . c o m 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()); } }
From source file:com.nuxeo.functionaltests.ITAssetViewTest.java
License:Open Source License
@Test public void testIntellectualProperty() throws Exception { login("leela", "test"); DAMPage damPage = getDAMPage();// ww w . j a va 2s . co m damPage = damPage.createAsset("File", "One File", "One File description", "Leela", "1/1/2012"); AssetViewFragment assetViewFragment = damPage.getAssetViewFragment(); FoldableBoxFragment ipBox = assetViewFragment.getFoldableBox("Intellectual Property", true); ipBox.checkTextToBeNotPresent("New holder"); ipBox.edit(); WebElement copyrightHolderInput = driver.findElement( By.id("nxl_gridDamLayout:nxw_damAssetViewIpRights_toggledForm:nxl_ip_rights:nxw_copyright_holder")); copyrightHolderInput.clear(); copyrightHolderInput.sendKeys("New holder"); ipBox.save(); Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(5, TimeUnit.SECONDS) .pollingEvery(100, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class); try { wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver driver) { return driver .findElement(By.xpath("//div[contains(.,'" + FILE_MODIFIED_NOTIFICATION_LABEL + "')]")); } }); } catch (TimeoutException e) { log.warn("Could not see saved message, maybe I was too slow and it " + "has already disappeared. Let's see if I can restore."); } ipBox.open(); ipBox.waitForTextToBePresent("New holder"); logout(); }
From source file:com.partnet.automation.HtmlView.java
License:Apache License
/** * Waits for an element to appear on the page before returning. Example: * WebElement waitElement =/* w ww .j a v a2s .c o m*/ * fluentWait(By.cssSelector(div[class='someClass'])); * * @param locator locator of the element to find * @return Web element of found element */ protected WebElement waitForElementToAppear(final By locator) { Wait<WebDriver> wait = new FluentWait<WebDriver>(webDriver).withTimeout(30, TimeUnit.SECONDS) .pollingEvery(5, TimeUnit.SECONDS).ignoring(NoSuchElementException.class); WebElement element = null; try { element = wait.until(new Function<WebDriver, WebElement>() { @Override public WebElement apply(WebDriver driver) { return driver.findElement(locator); } }); } catch (TimeoutException e) { try { // I want the error message on what element was not found webDriver.findElement(locator); } catch (NoSuchElementException renamedErrorOutput) { // print that error message renamedErrorOutput.addSuppressed(e); // throw new // NoSuchElementException("Timeout reached when waiting for element to be found!" // + e.getMessage(), correctErrorOutput); throw renamedErrorOutput; } e.addSuppressed(e); throw new NoSuchElementException("Timeout reached when searching for element!", e); } return element; }
From source file:com.pentaho.ctools.utils.ElementHelper.java
License:Apache License
/** * This method shall wait for the title and return it. The developer can * specify the timeout and pollingTime.// ww w .ja v a2 s . c o m * * * @param driver * @param title * @param timeout * @param pollingTime * @return */ public String WaitForTitle(final WebDriver driver, final String title, final Integer timeout, final Integer pollingTime) { this.log.debug("WaitForTitle::Enter"); String returnTitle = ""; driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); ExecutorService executor = null; try { class RunnableObject implements Runnable { private Boolean textIsEquals; public Boolean isTextEquals() { return this.textIsEquals; } @Override public void run() { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(timeout, TimeUnit.SECONDS) .pollingEvery(pollingTime, TimeUnit.MILLISECONDS); // Wait for element visible this.textIsEquals = wait.until(new Function<WebDriver, Boolean>() { @Override public Boolean apply(WebDriver d) { String currentTitle = driver.getTitle(); return currentTitle != null && currentTitle.contains(title); } }); } } RunnableObject r = new RunnableObject(); executor = Executors.newSingleThreadExecutor(); executor.submit(r).get(timeout + 2, TimeUnit.SECONDS); if (r.isTextEquals()) { // If the text is equals then send the text that we wait for. returnTitle = title; this.log.debug("Wait for text successful!"); } } catch (InterruptedException ie) { this.log.warn("Interrupted Exception"); this.log.warn(ie.toString()); } catch (ExecutionException ee) { if (ee.getCause().getClass().getCanonicalName() .equalsIgnoreCase(TimeoutException.class.getCanonicalName())) { this.log.warn("WebDriver timeout exceeded!"); } else { this.log.warn("Execution Exception"); this.log.warn(ee.toString()); } } catch (java.util.concurrent.TimeoutException cte) { this.log.warn("Thread timeout exceeded!"); this.log.warn(cte.toString()); } catch (Exception e) { this.log.error("Exception"); this.log.catching(e); } if (executor != null) { executor.shutdown(); } driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); this.log.debug("WaitForTitle::Exit"); return returnTitle; }