List of usage examples for org.openqa.selenium.support.ui FluentWait FluentWait
public FluentWait(T input)
From source file:org.nuxeo.functionaltests.AbstractTest.java
License:Open Source License
/** * Fluent wait for text to be present in the element retrieved with the * given method.//from w w w. ja v a2 s .com * * @since 5.7.3 */ public static void waitForTextPresent(By locator, String text) { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(LOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS) .pollingEvery(POLLING_FREQUENCY_SECONDS, TimeUnit.SECONDS); wait.until(ExpectedConditions.textToBePresentInElement(locator, text)); }
From source file:org.nuxeo.functionaltests.AbstractTest.java
License:Open Source License
/** * Fluent wait for text to be present in the given element. * * @since 5.7.3/*from www.j a va 2s.co m*/ */ public static void waitForTextPresent(final WebElement element, final String text) { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(LOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS) .pollingEvery(POLLING_FREQUENCY_SECONDS, TimeUnit.SECONDS); wait.until((new Function<WebDriver, Boolean>() { public Boolean apply(WebDriver driver) { try { return element.getText().contains(text); } catch (StaleElementReferenceException e) { return null; } } })); }
From source file:org.nuxeo.functionaltests.AbstractTest.java
License:Open Source License
/** * Fluent wait for text to be not present in the given element. * * @since 5.7.3/* w w w . ja v a2 s .com*/ */ public static void waitForTextNotPresent(final WebElement element, final String text) { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(LOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS) .pollingEvery(POLLING_FREQUENCY_SECONDS, TimeUnit.SECONDS); wait.until((new Function<WebDriver, Boolean>() { public Boolean apply(WebDriver driver) { try { return !element.getText().contains(text); } catch (StaleElementReferenceException e) { return null; } } })); }
From source file:org.nuxeo.functionaltests.dam.FoldableBoxFragment.java
License:Open Source License
public WebElement waitUntilElementPresent(final By locator) { Wait<WebDriver> wait = new FluentWait<>(driver) .withTimeout(AbstractTest.LOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS) .pollingEvery(AbstractTest.POLLING_FREQUENCY_SECONDS, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class); return wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver driver) { return element.findElement(locator); }//from w ww . j a v a 2 s . co m }); }
From source file:org.nuxeo.functionaltests.forms.Select2WidgetElement.java
License:Open Source License
/** * Select a single value.//from www .ja v a2 s . c o m * * @param value the value to be selected * * @since 5.7.3 */ public void selectValue(final String value) { WebElement select2Field = null; if (mutliple) { select2Field = element; } else { select2Field = element.findElement(By.xpath("a[contains(@class,'select2-choice select2-default')]")); } select2Field.click(); Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(SELECT2_LOADING_TIMEOUT, TimeUnit.SECONDS).pollingEvery(100, TimeUnit.MILLISECONDS) .ignoring(NoSuchElementException.class); WebElement suggestInput = null; if (mutliple) { suggestInput = driver.findElement(By.xpath("//ul/li[@class='select2-search-field']/input")); } else { suggestInput = driver.findElement(By.xpath(S2_SINGLE_INPUT_XPATH)); } char c; for (int i = 0; i < value.length(); i++) { c = value.charAt(i); suggestInput.sendKeys(c + ""); try { wait.until(mutliple ? s2MultipleWaitFunction : s2SingleWaitFunction); } catch (TimeoutException e) { if (i == (value.length() - 1)) { log.error("Suggestion definitly timed out with last letter : " + c + ". There is something wrong with select2"); throw e; } log.warn("Suggestion timed out with letter : " + c + ". Let's try with next letter."); } } WebElement suggestion = driver.findElement(By.xpath(S2_SUGGEST_RESULT_XPATH)); suggestion.click(); }
From source file:org.nuxeo.functionaltests.fragment.GadgetsContainerFragment.java
License:Open Source License
public WebElement waitForGadgetsLoad(final String mandatoryElements) { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(AbstractTest.LOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS).pollingEvery(5, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class); return wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver driver) { WebElement container = getElement(); // iterate through all frames, and ensure opensocial ones are // loaded, and expect at least one opensocial frame boolean oneFound = false; List<WebElement> framesList = driver.findElements(By.xpath("//iframe")); if (framesList != null && !framesList.isEmpty()) { List<String> mandatory = Arrays.asList(mandatoryElements.split(",")); for (WebElement frame : framesList) { String frameName = frame.getAttribute("name"); if (frameName == null || !frameName.startsWith("open-social")) { continue; }// ww w . j a v a 2s . c o m log.debug(String.format("Found one GWT gadget frame named '%s' ", frameName)); oneFound = true; boolean loaded = false; driver.switchTo().defaultContent(); driver.switchTo().frame(frame); for (String mand : mandatory) { try { driver.findElement(By.id(mand)); loaded = true; log.debug(String.format("Gadget frame '%s' mandatory element '%s' loaded", frameName, mand)); } catch (NoSuchElementException e) { loaded = false; log.debug(String.format( "Gadget frame '%s' not loaded yet, " + "mandatory element '%s' not found", frameName, mand)); break; } } if (!loaded) { log.debug(String.format("Gadget frame '%s' not loaded yet", frameName)); driver.switchTo().defaultContent(); return null; } log.debug(String.format("Gadget frame '%s' loaded", frameName)); driver.switchTo().defaultContent(); } } if (oneFound) { return container; } log.debug("No gadget frame loaded yet"); return null; } }); }
From source file:org.nuxeo.functionaltests.ITSafeEditTest.java
License:Open Source License
private void checkSafeEditRestoreProvided() { // We must find the status message asking if we want to restore // previous unchanged data, and make sure it is visible Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(5, TimeUnit.SECONDS) .pollingEvery(100, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class); wait.until(ExpectedConditions.textToBePresentInElement(By.className("ambiance-title"), "A draft of this document has been saved")); }
From source file:org.nuxeo.functionaltests.ITSafeEditTest.java
License:Open Source License
private void waitForSavedNotification() { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(5, TimeUnit.SECONDS) .pollingEvery(100, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class); try {/*from w w w. j a v a2 s . c o m*/ wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver driver) { return driver .findElement(By.xpath("//div[contains(.,'" + DRAFT_SAVE_TEXT_NOTIFICATION + "')]")); } }); } 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."); } }
From source file:org.nuxeo.functionaltests.Locator.java
License:Apache License
public static FluentWait<WebDriver> getFluentWait() { FluentWait<WebDriver> wait = new FluentWait<WebDriver>(AbstractTest.driver); wait.withTimeout(AbstractTest.LOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS) .pollingEvery(AbstractTest.POLLING_FREQUENCY_MILLISECONDS, TimeUnit.MILLISECONDS); return wait;/*from w w w. ja v a2 s . c o m*/ }
From source file:org.nuxeo.functionaltests.pages.tabs.RelationTabSubPage.java
License:Open Source License
public RelationTabSubPage initRelationSetUp() { addANewRelationLink.click();/*w w w .ja va2 s. c om*/ Function<WebDriver, Boolean> createRelationFormVisible = new Function<WebDriver, Boolean>() { public Boolean apply(WebDriver driver) { return createRelationForm != null; } }; Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(CREATE_FORM_LOADING_TIMEOUT, TimeUnit.SECONDS).pollingEvery(100, TimeUnit.MILLISECONDS) .ignoring(NoSuchElementException.class); wait.until(createRelationFormVisible); return asPage(RelationTabSubPage.class); }