4

Before updating Selenium.Support Nuget, all test cases in my test suite were running correctly. When I updated the Nuget yesterday, all my test cases in which I use WebDriverWait ExpectedConditions, have stopped working and keep failing at point, where WebDriverWait ExpectedConditions are used.

When I check information in my VS 2017 I can notice, that there is a message saying that ExpectedConditions is obsolete and it will be removed in the future release. I really do not want to stop using this feature, because it was very helpful for me.

My question is do you have any solution or suggestions how can I resolve this issue? I'm placing one of my examples method, where I use ExpectedConditions.

public bool IsAtHomePage()
    {
        WebDriverWait wait = new WebDriverWait(Browser.WebDriver, TimeSpan.FromSeconds(10));
        wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("custom-tree")));

        return Browser.Url == HomePageUrl;
    }
2
  • Have you tried to debug the code to watch the real state of the things before you call wait.Until?
    – Alexey R.
    Commented Mar 16, 2018 at 10:39
  • Hello Alexey R. I have tried debugging and it keeps failing at the same point, however, I did some more googling and found out to replace the ExpectedConditions with solution given in this link -> stackoverflow.com/questions/23479538/… Commented Mar 16, 2018 at 11:51

3 Answers 3

4

The set of expected conditions is being removed from the Selenium C# bindings.

Though you can still add them to your library from the source:

https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/support/UI/ExpectedConditions.cs

Or you can update/migrate your code to use SeleniumExtras.ExpectedConditions, the external library where they are being moved to:

https://github.com/DotNetSeleniumTools/DotNetSeleniumExtras

0
0

All top software testing companies use selenium for automation. In the problem mentioned above the version of the selenium is upgraded to latest version in NUget package manager, due to which 'WebDriverWait ExpectedConditions' class is obsolete.

In order to use 'WebDriverWait ExpectedConditions' class 'Selenium.Support' NuGet packages need to be installed. or

The other way is to use 'DotNetSeleniumExtras.WaitHelpers'

Example Code is:

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

0

VisualStudio warns that ExpectedConditions has now become Obsolete there are Nuget packages which solve this issue.

Solutions:

  1. We can either downgrade to version which support Expected Conditions or

  2. By using wait.until

    new WebDriverWait(webDriver, TimeSpan.FromSeconds(10)).Until(c => c.FindElement(By.Id("name")));

Your Answer

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

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