Search This Blog

July 25, 2018

Fixed the warning: ExpectedConditions' is obsolete in Selenium

Today I tried to clean up some code. The following warning was interesting. 
bool result = wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("esi-promo-text"))).Displayed; 

Warning    CS0618    'ExpectedConditions' is obsolete: 'The ExpectedConditions implementation in the .NET bindings is deprecated and will be removed in a future release. This portion of the code has been migrated to the DotNetSeleniumExtras repository on GitHub (https://github.com/DotNetSeleniumTools/DotNetSeleniumExtras)'     

After looking into this issue, it was easy to update the code. 

In Visual Studio, right click Project file and click Manage NuGet Packages. 
Search DotNetSeleniumExtras.WaitHelpers. Install it. 
Import the namespace: using WaitHelpers = SeleniumExtras.WaitHelpers; 
Update the method. 

bool result = wait.Until(WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("esi-promo-text"))).Displayed; 

Built solution in Visual Studio and the warning disapppeared 

No comments: