The selenium web driver seems to be indicating that OpenQA.Selenium.Support.UI.ExpectedConditions method is now deprecated, I would humbly ask for some assistance in rewriting the below statement, achieving the same outcome.

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(3));  

I recently replaced all our Wait.Until(ExpectedConditions.ElementToBeVisible(By.IDK(element)) to

Wait.Until(driver => driver.FindElement(By.IDK(element)).IsVisible());

| improve this answer | |
  • Thanks Doug, I will check whether the InvisibilityOfElementLocated method is available using your suggestion. – BernardV Jan 10 '19 at 18:58
  • You wont be able to use "InvisibilityOfElementLocated" as it is a method within ExpectedConditions, instead use selenium IWebElement.isVisible() and negate it. !IWebElement.isVisible() – Doug Clark Jan 10 '19 at 20:27

They have moved the ExpectedConditions to another package that won't be maintained (unless someone steps forward).

The easiest (and cleanest) solution is to simply create a class in your framework where you can copy any ExpectedConditions you want to use. Even better, you can add your own as well.

So start from the actual class code (https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/support/UI/ExpectedConditions.cs) and rename the class to MyConditions, for example.

Usage would be:

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(3));  
| improve this answer | |
  • Thanks for your feedback @FDM, this does make sense, I just wonder did the Selenium team not create something better / a new method that supersedes ExpectedConditions class? – BernardV Jan 11 '19 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.