ImplicitWait
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);Explicit Wait
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(3));
IWebElement element = wait.Until(ExpectedConditions.ElementExists(By.Id("foo")));
IWebElement element = wait.Until(ExpectedConditions.ElementExists(By.Id("foo")));
Fluent Wait
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(2));
Func<IWebDriver, bool> waitForElement = new Func<IWebDriver, bool>((IWebDriver Web) =>
{
IWebElement element = //use locators such as xpath;
if (element.Displayed)
{
return true;
}
return false;
});
wait.Until(waitForElement);
Func<IWebDriver, bool> waitForElement = new Func<IWebDriver, bool>((IWebDriver Web) =>
{
IWebElement element = //use locators such as xpath;
if (element.Displayed)
{
return true;
}
return false;
});
wait.Until(waitForElement);