How to WAIT in Selenium web driver using C#

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")));

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);








Copyright © 2017 qatoolsguide.blogspot.com || ALL RIGHTS RESERVED