3

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));  
wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.Id(newNoteInputArea)));

2 Answers 2

1

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

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

2
  • Thanks Doug, I will check whether the InvisibilityOfElementLocated method is available using your suggestion.
    – BernardV
    Jan 10, 2019 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, 2019 at 20:27
0

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));  
wait.Until(MyConditions.InvisibilityOfElementLocated(By.Id(newNoteInputArea)));
1
  • 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, 2019 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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