Search This Blog

July 27, 2018

Fixed the Firefox issue in Selenium : out of bounds of viewport width (1600) and height (786)

Today I used Firefox 61 to run some tests and 2 tests failed due to the following error. 

System.InvalidOperationException : (345.816650390625, 789.8833312988281) is out of bounds of viewport width (1600) and height (786) (MoveTargetOutOfBounds) 

2 tests are running fine in Chrome and Microsoft Edge.  

After looking into this issue, it looks like there is the bug in Gecko Driver about the viewpoint width and height of Firefox. In order to let the tests pass, I need to add the code to handle this issue. 

Since the Firefox has the issue related to out of bounds of viewpoint width and height, the quickest way to handle it is to add ScrollDown() method. 

After adding it and running the tests, 2 tests pass without any issue.  

       public void ScrollDown() 

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 == 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 ('     

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