SynchronisationService extends BaseServiceHub { public boolean waitForExpectedCondition(ExpectedCondition<?> condition, int timeout) { WebDriver driver = getWebDriver(); boolean conditionMet = true; try { new WebDriverWait(driver, timeout).until(condition); } catch (TimeoutException e) { conditionMet = false; } return conditionMet; }  boolean waitForExpectedCondition(ExpectedCondition<?> condition, int timeout); boolean waitForExpectedCondition(ExpectedCondition<?> condition); void waitAndAssertForExpectedCondition(ExpectedCondition<?> condition, int timeout); void waitAndAssertForExpectedCondition(ExpectedCondition<?> condition); boolean checkForExpectedCondition(ExpectedCondition<?> condition); void checkAndAssertForExpectedCondition(ExpectedCondition<?> condition); void waitAndSwitchToNewBrowserWindow(int timeout); void waitAndSwitchToNewBrowserWindow(); void switchToMainWindow(); void switchToLatestPopupWindow();  }
@Test public void testWaitForExpectedCondition() throws Exception { seleniumNavigationService.navigate_to_url(TEST_PAGE_URL); assertTrue(seleniumSynchronisationService.waitForExpectedCondition(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[id='text']")), seleniumManager.getTimeout())); seleniumElementService.findExpectedElement(By.cssSelector("button[id='delayedDisplayButton']")).click(); assertTrue(seleniumSynchronisationService.waitForExpectedCondition(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id='text']")), seleniumManager.getTimeout())); }