@Override public FluentWait<WebDriver, FLUENT> withMessage(String message) { wait.withMessage(message); return this; }
@Override public FluentWait<WebDriver, FLUENT> withMessage(String message) { wait.withMessage(message); return this; }
public void waitUntilReady() { WebDriverWait waiter = new WebDriverWait(getWebDriver(), 30); waiter.withMessage("\"" + getElementName() + "\" is not ready in 30 seconds") .until(new Predicate<WebDriver>() { @Override public boolean apply(WebDriver input) { /* isReady() returns true if all elements * that you need to test are available. * Note that if you have javascript, you * should have some hidden field to tell * you that the whole page has loaded. */ return isReady(); } }); }
/** * Creates an instance of the {@link FluentWait} with specified {@code timeoutInSec} and error * message supplier. * * @param timeoutInSec waiting time in seconds. * @param messageSupplier error message supplier * @return */ public FluentWait<WebDriver> get(int timeoutInSec, Supplier<String> messageSupplier) { return new WebDriverWait(seleniumWebDriver, timeoutInSec).withMessage(messageSupplier); }
WebDriverWait wait = new WebDriverWait(driver, timeout); wait.withMessage("Any message you want"); wait.until(ExpectedConditions.titleIs(title));
public Object executeScriptAndWaitOutput(final String command) { WebDriverWait wait = new WebDriverWait(driver, timeout); wait.withMessage("Timeout executing script: " + command); final Object[] out = new Object[1]; wait.until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { try { out[0] = executeScript(command); } catch (WebDriverException we) { log.warn("Exception executing script", we); out[0] = null; } return out[0] != null; } }); return out[0]; }
public Object executeScriptAndWaitOutput(final String command) { WebDriverWait wait = new WebDriverWait(driver, timeout); wait.withMessage("Timeout executing script: " + command); final Object[] out = new Object[1]; wait.until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { try { out[0] = executeScript(command); } catch (WebDriverException we) { log.warn("Exception executing script", we); out[0] = null; } return out[0] != null; } }); return out[0]; }
@Step public void search(String text) { driver.findElement(By.id("text")).sendKeys(text); driver.findElement(By.className("suggest2-form__button")).submit(); new WebDriverWait(driver, 10) .withMessage("Could not load results page") .until(mainContainLoaded()); }
/** * Waits during the standard timeout for the condition specified by the {@link ExpectedCondition} parameter. * For example, to wait for an element to invisible by its locator {@code ExpectedConditions.invisibilityOfElementLocated (by)} * * @param condition check condition * @param message message in case verification failed * @param timeout condition timeout in seconds */ public static void wait(ExpectedCondition condition, String message, int timeout) { new WebDriverWait(Environment.getDriverService().getDriver(), timeout) .withMessage(message).until(condition); } }
/** * Waits during the standard timeout for the condition specified by the {@link ExpectedCondition} parameter. * For example, to wait for an element to invisible by its locator {@code ExpectedConditions.invisibilityOfElementLocated (by)} * * @param condition check condition * @param message message in case verification failed */ public static void wait(ExpectedCondition condition, String message) { new WebDriverWait(Environment.getDriverService().getDriver(), PROPERTIES.getTimeout()) .withMessage(message).until(condition); }