protected void waitFor(By by, long poll, long timeout) { FluentWait<By> fluentWait = new FluentWait<By>(by); fluentWait.pollingEvery(poll, TimeUnit.MILLISECONDS); fluentWait.withTimeout(timeout, TimeUnit.SECONDS); fluentWait.until( new Predicate<By>() { public boolean apply(By by) { try { List<WebElement> results = rootElement.findElements(by); return !results.isEmpty() && results.get(0).isDisplayed(); } catch (NoSuchElementException ex) { return false; } } }); }