@Override public FluentWait<WebDriver, FLUENT> withTimeout(long duration, TimeUnit unit) { wait.withTimeout(duration, unit); return this; }
@Override public FluentWait<WebDriver, FLUENT> withTimeout(long duration, TimeUnit unit) { wait.withTimeout(duration, unit); return this; }
private boolean waitUntilLoginPage() { try { selenium.getDriverWait().withTimeout(Duration.ofSeconds(3)).until(ExpectedConditions.titleContains("Login")); return true; } catch (Exception ex) { return false; } }
@Override public void checkReachableWebPage() { String pageTitle = "Log"; selenium.getDriverWait().withTimeout(Duration.ofSeconds(60)).until(ExpectedConditions.titleContains(pageTitle)); } }
/** * Executes condition until it returns a value other than null or false. * It does not forward StaleElementReferenceExceptions, but keeps waiting. * @param maxSecondsToWait number of seconds to wait at most. * @param condition condition to check. * @param <T> return type. * @return result of condition (if not null). * @throws TimeoutException when condition did not give a value to return after maxSecondsToWait. */ public <T> T waitUntil(int maxSecondsToWait, ExpectedCondition<T> condition) { ExpectedCondition<T> cHandlingStale = getConditionIgnoringStaleElement(condition); FluentWait<WebDriver> wait = waitDriver().withTimeout(Duration.ofSeconds(maxSecondsToWait)); return wait.until(cHandlingStale); }
@Override public void checkReachableWebPage() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(60)).until(ExpectedConditions.presenceOfElementLocated(By.className("nav-pf-vertical"))); } }
@Override public void checkReachableWebPage() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(60)).until(ExpectedConditions.presenceOfElementLocated(By.className("navbar-pf-vertical"))); } }
private void waitForRedirectToService() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(60)).until(ExpectedConditions.presenceOfElementLocated(By.tagName("service-instance-row"))); }
@Override public void checkReachableWebPage() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(30)).until(ExpectedConditions.presenceOfElementLocated(By.id("inputPassword"))); selenium.getAngularDriver().waitForAngularRequestsToFinish(); selenium.takeScreenShot(); } }
private WebElement getNavigateMenu() throws Exception { selenium.getDriverWait().withTimeout(Duration.ofSeconds(30)).until(ExpectedConditions.presenceOfElementLocated(By.className("nav-pf-vertical"))); return selenium.getDriver().findElement(By.className("nav-pf-vertical")); }
@Test(enabled=true) public void dependentDropdown(){ WebDriver driver = new FirefoxDriver(); driver.get("http://phppot.com/demo/jquery-dependent-dropdown-list-countries-and-states/"); driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 30); Select country = new Select(wait.until(ExpectedConditions.presenceOfElementLocated(By.id("country-list")))); country.selectByVisibleText("India"); FluentWait<WebElement> waitFor_state_list_population = new FluentWait<WebElement>(driver.findElement(By.id("state-list"))); wait.withTimeout(60, TimeUnit.SECONDS).pollingEvery(1, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class); com.google.common.base.Function<WebElement, Boolean> elementLoaded = new com.google.common.base.Function<WebElement, Boolean>() { @Override public Boolean apply(WebElement ele) { return ele.getTagName().equals("select")? new Select(ele).getOptions().size()>5? true: false: false; } }; if(waitFor_state_list_population.until(elementLoaded)){ Select state = new Select(driver.findElement(By.id("state-list"))); state.selectByVisibleText("Delhi"); } driver.close(); driver.quit(); }
private void waitUntilServiceIsReady() throws Exception { getProvisionedServiceItem().expandServiceItem(); log.info("Waiting until provisioned service will be completed"); selenium.takeScreenShot(); selenium.getDriverWait().withTimeout(Duration.ofMinutes(5)).until(ExpectedConditions.numberOfElementsToBe(By.className("alert-info"), 0)); selenium.takeScreenShot(); }