/** * Waits until an element is no longer attached to the DOM or the timeout expires. * @param element the WebElement * @throws org.openqa.selenium.TimeoutException if the timeout defined in * {@link TestProperties#TEST_TIMEOUT} expires * @see org.openqa.selenium.support.ui.FluentWait#until(com.google.common.base.Function) */ public void waitForElementStaleness(WebElement element) { waitFor(ExpectedConditions.stalenessOf(element)); }
if (isExpectedCondition(ExpectedConditions.stalenessOf(element))) { throw new AssertionError( "Element is stale but should have been caught earlier by element.isEnabled().");
public static void clear(WebDriver driver, String id) { List<WebElement> elements = driver.findElements(byCloseChoices(id)); for (WebElement element : elements) { element.click(); new WebDriverWait(driver, CLEAR_TIME_OUT).until(stalenessOf(element)); } }
public boolean waitUntilElementDisappear(final long timeout) { try { //TODO: investigate maybe searchContext better to use here! //do direct selenium/appium search without any extra validations if (searchContext != null) { //TODO: use-case when format method is used. Need investigate howto init context in this case as well element = searchContext.findElement(by); } else { LOGGER.error("waitUntilElementDisappear: searchContext is null for " + getNameWithLocator()); element = getDriver().findElement(by); } } catch (NoSuchElementException e) { //element not present so means disappear return true; } catch (Exception e) { //element not present so means disappear LOGGER.error("Investigate use-case with disappeared element later!", e); return true; } return waitUntil(ExpectedConditions.or(ExpectedConditions.invisibilityOfElementLocated(getBy()), ExpectedConditions.stalenessOf(element), ExpectedConditions.invisibilityOf(element)), timeout); }