Search This Blog

July 27, 2018

Fixed the issue : jQuery is not defined after upgrading to the new Selenium Driver

Today I upgraded Selenium.Driver and Selenium.Support to v.3.13.1. After running some tests, they failed.  We have the WaitForAjax() method where the first line in C# was as follows:

bool isAjaxDone = ((bool)((IJavaScriptExecutor)_driver).ExecuteScript("return jQuery.active == 0")); 

The interesting part was that this method was created 2 years ago and there was no issue in Selenium 2 and Selenium v.3.11 until I upgraded to v.3.13.1. 

After the upgrade, this line showed the following error directly and ended the test. Using try catch did not work either. 
unknown error: jQuery is not defined 

After updating the code to the following one, the tests pass without any issue. 
bool jQueryDefined = ((bool)((IJavaScriptExecutor)_driver).ExecuteScript("return typeof jQuery != 'undefined'")); 
if (jQueryDefined ) 
{ 
       Other code... 
}    

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.