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 

June 26, 2018

The specific Micrisoft Edge driver is tied to specific Windows 10 version

I saw some updates in NuGet Package in Visual Studio 2015. Therefore I installed the new Microsoft Edge Driver (Selenium.WebDriver.MicrosoftDriver v17.17134.0). When running one test in Microsoft Edge, it showed the following error.  


Finally I realized that the specific Edge driver is tied to specific Windows 10 version. It means the 17134 version is only for the 17134 machine. If I am on 16299.xxx machine , it is required to use the 16299 version of Microsoft Edge driver. 


The drivers of Chrome, Firefox and IE are not tied to specific Windows version. I cannot believe the Microsoft Edge driver is tied to specific Windows version. 

March 12, 2018

The feature, options.AddArgument("disable-infobars"), has been removed as of Chrome 65.

I upgraded Chrome Driver to 2.36 and currently use Chrome version 65. I notice that when running automation, the info bar "Chrome is being controlled by automated test software" always appears.  



After looking into this issue, it is not related to the Chrome driver. It is related to Chrome version.  

Before Chrome 65, the following syntax in C# was always working and the info bar went away . 

 options.AddArgument("disable-infobars");

In Chrome 65, the following syntax has been removed. I tried different ways to close it, but it does not work at this moment.  

Fortunately, it does not impact our automation. I do see some people in the forum complaining about the failures due to this major change.  

I do not believe there is the quick workaround to close this info bar at this moment because they add it intentionally. 

August 7, 2017

Fixed the failed build in Bamboo: This project references NuGet package(s) that are missing on this computer

I used the Manage NuGet Packages to upgrade Chrome Driver and IE driver .  Using Visual Studio 2015 to build the solution does not cause any error. After the code review and the pull request was merged to Master Branch, I saw the failed build in Bamboo. 

Here was the error:  
 This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.  The missing file is ..\packages\Selenium.WebDriver.ChromeDriver.2.31.0\build\Selenium.WebDriver.ChromeDriver.targets.  (EnsureNuGetPackageBuildImports target) his project references NuGet package(s) that are missing on this computer. 


After looking into this interesting issue, right clicked the project file and unloaded the project file. I could see the following code inside. After removing the code (Pink part) and the pull request was merged to Master Branch, the build succeeded in Bamboo. 


August 1, 2017

The device names of mobile emulation are changed in Selenium Chrome Driver 2.30

I upgraded the Chrome Driver to 2.30 in our test framework last month. When running the tests in iPhone emulator in Chrome, I got the following error.  

OneTimeSetUp: System.InvalidOperationException : unknown error: cannot parse capability: chromeOptions from unknown error: cannot parse mobileEmulation from unknown error: 'Apple iPhone 6' must be a valid device from unknown error: must be a valid device   (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64) 

After looking into this issue, I noticed that in Chrome driver 2.30, the device names are changed in options.EnableMobileEmulation() method. 

Apple iPhone 6 is changed to iPhone 6.
Apple iPad is changed to iPad.
Google Nexus 10 is changed to Nexus 10. 
Samsung Galaxy S5 is changed to Galaxy S5. 

After changing the device names and running the tests, all tests passed. 

February 23, 2017

Selenium: How to get the scroll position?

I have one test case I need to check the scroll position. If I click the url on the page, it will scroll down to the bottom of the page.

After looking into this interesting feature, here is the code I use in different browsers.

Before clicking the url, the value will be 0. After clicking the url , the value will be different.

public long GetScrollPosition()
{
  IJavaScriptExecutor executor = (IJavaScriptExecutor)_driver;
  return (long)executor.ExecuteScript("return window.pageYOffset;");

}