Wait verify using "ExpectedConditions" does not work Wait verify using "ExpectedConditions" does not work selenium selenium

Wait verify using "ExpectedConditions" does not work


I've seen this before.

Make sure you've installed both the Selenium.Webdriver and Selenium.Support NuGet packages for your project. You'll need the Selenium.Support package to use ExpectedConditions.


I resloved this way:

1: Using nuget, search for DotNetSeleniumExtras.WaitHelpers,

2: Import that namespace into your class.

    using SeleniumExtras.WaitHelpers

3: Then run the following code:

    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));    wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("element ID")));


I don't understand this line:

IWebElement element = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[2]/div/input")));

How are you able to cast Until to an IWebElement since it returns bool? I might be missing something.

But you might be able to bypass the error if you don't use ExpectedConditions, like so:

wait().Until( foo => driver.FindElement(By.XPath("//div[2]/div/input")).Enabled);

WebDriverWait takes as a parameter a function that returns a bool. You can create one within the parameters with the above code, that will return true when the element is enabled.