public static ExpectedCondition < Boolean > stalenessOf ( final WebElement element ) { return new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver ignored ) { try { // Calling any method forces a staleness check element . isEnabled ( ) ; return false ; } catch ( StaleElementReferenceException expected ) { return true ; } } @ Override public String toString ( ) { return String . format ( "element (%s) to become stale" , element ) ; } } ; }
Wait until an element is no longer attached to the DOM .