public static ExpectedCondition<Boolean> done(final Activity activity){ return new DelayingExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { return !activity.busyOn(driver); } @Override public String toString() { return activity.toString() + " to be done"; } @Override public Duration initialDelay() { return activity.initialDelay(); } }; }
private void sleepSeconds(long seconds) { try { Sleeper.SYSTEM_SLEEPER.sleep(new Duration(seconds, java.util.concurrent.TimeUnit.SECONDS)); } catch (InterruptedException e) { e.printStackTrace(); } }
private void sleep(long ms) { try { Sleeper.SYSTEM_SLEEPER.sleep(new Duration(ms, java.util.concurrent.TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { e.printStackTrace(); } }
public void sleep(Duration duration) { try { Sleeper.SYSTEM_SLEEPER.sleep(duration); } catch (InterruptedException e) { throw new RuntimeException(e); } }
public Duration getInitialAjaxDelayForDriver() { WebDriver webDriver = activeDriver(); if (webDriver instanceof HtmlUnitDriver) { return null; //new Duration(0, MILLISECONDS); } else if (webDriver instanceof ChromeDriver) { return null; } else { return new Duration(1, SECONDS); } }
public SeleniumWait(WebDriver input) { super(input, new SystemClock(), new Sleeper() { @Override public void sleep(Duration duration) { } }); ignoring(NoSuchElementException.class, StaleElementReferenceException.class); pollingEvery(100, TimeUnit.MILLISECONDS); }
private DemoApplication(final WebDriver driver) { super(driver); try { Sleeper.SYSTEM_SLEEPER.sleep(new Duration(5, TimeUnit.SECONDS)); } catch (InterruptedException e) { throw new RuntimeException("cannot wait", e); } }
public DemoDragMultiple revealDemoDragMultiple() { try { Sleeper.SYSTEM_SLEEPER.sleep(new Duration(5, TimeUnit.SECONDS)); return new DemoDragMultiple(driver, this).reveal(); } catch (InterruptedException e) { throw new RuntimeException("do the thing "); } }
protected void waitMillis(long timeout) throws InterruptedException { Sleeper.SYSTEM_SLEEPER.sleep(new Duration(timeout, TimeUnit.MILLISECONDS)); }
public RetryStatement(Properties properties) { this.timeout = new Duration(Long.parseLong(properties.getProperty(TIMEOUT_KEY, "5")), TimeUnit.SECONDS); this.polling = new Duration(Long.parseLong(properties.getProperty(POLLING_KEY, "250")), TimeUnit.MILLISECONDS); this.ignoring = new ArrayList<>(); }
public RetryStatement withTimeout(long time, TimeUnit unit) { this.timeout = new Duration(time, unit); return this; }
public RetryStatement pollingEvery(long time, TimeUnit unit) { this.polling = new Duration(time, unit); return this; }
private <V> void waitForInitialDelay(DelayingExpectedCondition<V> delayingExpectedCondition) { Duration initialDelay = delayingExpectedCondition.initialDelay(); if (initialDelay != null) { sleep(initialDelay); } }
@Override public Duration initialDelay() { return WebDriverFactory.getInstance().getInitialAjaxDelayForDriver(); }
public DefaultTimeout() { this.duration = new Duration(DEFAULT_TIMEOUT_SECS, TimeUnit.SECONDS); }
@Override public Duration getDuration() { return duration; }
public static Timeout timeoutIn(final long time, final TimeUnit unit) { return () -> new Duration(time, unit); }
public Duration initialDelay();
Duration getDuration();