@Override public <K extends Throwable> FluentWait<WebDriver, FLUENT> ignoring(Class<? extends Throwable> exceptionType) { wait.ignoring(exceptionType); return this; }
@Override public <K extends Throwable> FluentWait<WebDriver, FLUENT> ignoring(Class<? extends Throwable> firstType, Class<? extends Throwable> secondType) { wait.ignoring(firstType, secondType); return this; }
@Override public <K extends Throwable> FluentWait<WebDriver, FLUENT> ignoring(Class<? extends Throwable> exceptionType) { wait.ignoring(exceptionType); return this; }
@Override public <K extends Throwable> FluentWait<WebDriver, FLUENT> ignoring(Class<? extends Throwable> firstType, Class<? extends Throwable> secondType) { wait.ignoring(firstType, secondType); return this; }
final public static boolean waitForElToBeRemove(WebDriver driver, final By by) { try { driver.manage().timeouts() .implicitlyWait(0, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(UITestBase.driver, DEFAULT_TIMEOUT); boolean present = wait .ignoring(StaleElementReferenceException.class) .ignoring(NoSuchElementException.class) .until(ExpectedConditions.invisibilityOfElementLocated(by)); return present; } catch (Exception e) { return false; } finally { driver.manage().timeouts() .implicitlyWait(DEFAULT_TIMEOUT, TimeUnit.SECONDS); } }
final public static boolean waitForElToBeRemove(WebDriver driver, final By by) { try { driver.manage().timeouts() .implicitlyWait(0, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(UITestBase.driver, DEFAULT_TIMEOUT); boolean present = wait .ignoring(StaleElementReferenceException.class) .ignoring(NoSuchElementException.class) .until(ExpectedConditions.invisibilityOfElementLocated(by)); return present; } catch (Exception e) { return false; } finally { driver.manage().timeouts() .implicitlyWait(DEFAULT_TIMEOUT, TimeUnit.SECONDS); } }
@Provides @Singleton @Named("frameWait") public WebDriverWait provideWebDriverWaitByFrame(WebDriver driver, Configuration configuration) { WebDriverWait webDriverWait = new WebDriverWait(driver, configuration.getPageTimeOut(), configuration.getPollingTime() < 0 ? POLLING_TIME : configuration.getPollingTime()); webDriverWait .ignoring(NoSuchElementException.class, StaleElementReferenceException.class); return webDriverWait; }
private static void waitForConditionIgnoring(ExpectedCondition<?> condition, Class<? extends Throwable> ignoring, long timeoutInSeconds) { new WebDriverWait(Grid.driver(), timeoutInSeconds).ignoring(ignoring).until(condition); }
WebDriverWait wait = new WebDriverWait(driver, 10); wait.ignoring(NoSuchElementException.class); final String testName = ""; final WebElement wsearchlist = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(""))); WebElement wsearch = wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver input) { By by = new By.ByLinkText(testName); WebElement search = null; search = wsearchlist.findElement(by); return search; }}); //Continue on.
@Provides @Singleton @Named("default") public WebDriverWait provideWebDriverWait(WebDriver driver, Configuration configuration) { WebDriverWait webDriverWait = new WebDriverWait(driver, configuration.getExplicitTimeOut() < 0 ? EXPLICIT_TIME : configuration.getExplicitTimeOut(), configuration.getPollingTime() < 0 ? POLLING_TIME : configuration.getPollingTime()); webDriverWait .ignoring(NoSuchElementException.class, StaleElementReferenceException.class); return webDriverWait; }
/** * Wait until any condition happens. * * @param condition - ExpectedCondition. * @param timeout - timeout. * @return true if condition happen. */ public boolean waitUntil(ExpectedCondition<?> condition, long timeout) { boolean result; final WebDriver drv = getDriver(); Timer.start(ACTION_NAME.WAIT); Wait<WebDriver> wait = new WebDriverWait(drv, timeout, RETRY_TIME).ignoring(WebDriverException.class) .ignoring(NoSuchSessionException.class); try { wait.until(condition); result = true; LOGGER.debug("waitUntil: finished true..."); } catch (NoSuchElementException | TimeoutException e) { // don't write exception even in debug mode LOGGER.debug("waitUntil: NoSuchElementException | TimeoutException e..." + condition.toString()); result = false; } catch (Exception e) { LOGGER.error("waitUntil: " + condition.toString(), e); result = false; } Timer.stop(ACTION_NAME.WAIT); return result; }
Wait wait = new WebDriverWait(webDriver, timeout, RETRY_TIME).ignoring(WebDriverException.class) .ignoring(NoSuchSessionException.class); try {
public void waitUntil(Predicate<WebDriver> predicate, int timeInSeconds) { WebDriverWait wait = new WebDriverWait(webDriver, timeInSeconds); wait.ignoring(StaleElementReferenceException.class); wait.until(new java.util.function.Function<WebDriver, Boolean>() { @Override public Boolean apply(WebDriver webDriver) { return predicate.apply(webDriver); } }); }
public <T> T waitFor(Function<WebDriver, T> function) { WebDriverWait wait = new WebDriverWait(webDriver, TIMEOUT_SECONDS); wait.ignoring(StaleElementReferenceException.class); return wait.until(function); }
public <T> void waitUntil(ExpectedCondition<T> condition) { WebDriverWait wait = new WebDriverWait(webDriver, TIMEOUT_SECONDS); wait.ignoring(StaleElementReferenceException.class); wait.until(condition); }
/** * Asserts that all {@link ElementMustExist}s fields are visible in this * page object. */ @Override protected void assertInModule() { driver.manage().timeouts().implicitlyWait(pollingMillis, TimeUnit.MILLISECONDS); for (final Field currField: this.getClass().getDeclaredFields()) { currField.setAccessible(true); if (currField.isAnnotationPresent(ElementMustExist.class)) { By by = new Annotations(currField).buildBy(); report.report("Waiting for Element (@ElementMustExist): " + by); final WebDriverWait wait = new WebDriverWait(driver, getAjaxTimeout()); wait.ignoring(WebDriverException.class); wait.pollingEvery(100, TimeUnit.MILLISECONDS); wait.until(ExpectedConditions.visibilityOfElementLocated(by)); } } }
Wait<WebDriver> wait = new WebDriverWait(drv, timeout, RETRY_TIME).ignoring(WebDriverException.class) .ignoring(NoSuchSessionException.class);
public FluentElement waitFor(By by, int timeout) { WebDriverWait wait = new WebDriverWait(webDriver, timeout); wait.ignoring(StaleElementReferenceException.class); WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(by)); return new FluentElement(webDriver, element); }