Question: I am testing a UI in which the user clicks a delete button and a table entry disappears. As such, I want to be able to check that the table entry no longer exists.

I have tried using `ExpectedConditions.not()` to invert `ExpectedConditions.presenceOfElementLocated()`, hoping that it would mean "expect that there is not a presence of the specified element". My code is like so:

```
browser.navigate().to("http://stackoverflow.com");
new WebDriverWait(browser, 1).until(
        ExpectedConditions.not(
                ExpectedConditions.presenceOfElementLocated(By.id("foo"))));

```

However, I found that even doing this, I get a `TimeoutExpcetion` caused by a `NoSuchElementException` saying that the element "foo" does not exist. Of course, having no such element is what I want, but I don't want an exception to be thrown.

So how can I wait until an element no longer exists? I would prefer an example that does not rely on catching an exception if at all possible (as I understand it, exceptions should be thrown for exceptional behavior).

Answer: 
Why don't you simply find the size of `elements`. We know the the collection of elements' *size* would be **0** if *element* does not exist.

```
if(driver.findElements(By.id("foo").size() > 0 ){
    //It should fail
}else{
    //pass
}

```
I found a workaround to fix this for me in efficient way, used following C# code to handle this, you may convert it to Java

```
    public bool WaitForElementDisapper(By element)
    {
        try
        {
            while (true)
            {
                try
                {
                    if (driver.FindElement(element).Displayed)
                        Thread.Sleep(2000);
                }
                catch (NoSuchElementException)
                {
                    break;
                }
            }
            return true;
        }
        catch (Exception e)
        {
            logger.Error(e.Message);
            return false;
        }
    }

```