When trying to explicitly wait for an element to become visible using ExpectedConditions, Visual Studio warns me that it is now obsolete and will be removed from Selenium so
If you don't want to download an extra nuget package, it is quite easy to declare your own function (or condition), especially using a lamda expression, e.g.
var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
var element = wait.Until(condition =>
{
try
{
var elementToBeDisplayed = driver.FindElement(By.Id("content-section"));
return elementToBeDisplayed.Displayed;
}
catch (StaleElementReferenceException)
{
return false;
}
catch (NoSuchElementException)
{
return false;
}
});
This is also very versitile, since it is now possible to evaluate any kind of bool-expression.