C# Selenium 'ExpectedConditions is obsolete'

前端 未结 7 1816
灰色年华
灰色年华 2020-11-28 04:51

When trying to explicitly wait for an element to become visible using ExpectedConditions, Visual Studio warns me that it is now obsolete and will be removed from Selenium so

7条回答
  •  猫巷女王i
    2020-11-28 05:15

    I solved my own question and wanted to provide the answer for anyone else wondering how to resolve this with the latest version of Selenium.

    Using nuget, search for DotNetSeleniumExtras.WaitHelpers, import that namespace into your class. Now you can do this:

    var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
    var element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("content-section")));
    

    And the warning in the IDE will be gone.

提交回复
热议问题