In the code below, I attempt to wait until an element is visible:
var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(10));
wait.Until(ExpectedCon
As of 2020, ExpectedConditions is deprecated in .NET.
For some reason, I was not able to make IgnoreExceptionTypes work.
The only solution that worked for me was the one proposed by Anoop. One thing I like about his solution is it returns as soon as the element becomes invisible.
I generalized his solution a bit as follows:
//returns as soon as element is not visible, or throws WebDriverTimeoutException
protected void WaitUntilElementNotVisible(By searchElementBy, int timeoutInSeconds)
{
new WebDriverWait(_driver, TimeSpan.FromSeconds(timeoutInSeconds))
.Until(drv => !IsElementVisible(searchElementBy));
}
private bool IsElementVisible(By searchElementBy)
{
try
{
return _driver.FindElement(searchElementBy).Displayed;
}
catch (NoSuchElementException)
{
return false;
}
}
Usage:
WaitUntilElementNotVisible(By.Id("processing"), 10);