Search This Blog

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;");

}

September 5, 2016

Selenium: Fixed the issue of unknown error: Element is not clickable at point (X, Y). Other element would receive the click

Today, one test failed. After looking into this issue, I noticed that when Selenium Web Driver tried to click the button, it showed the following error.

Message = "unknown error: Element is not clickable at point (1055, 224). Other element would receive the click:

...

\n  (Session info: chrome=52.0.2743.116)\n  (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),pl...

The source code is easy. Just use Element.Click. It works in Firefox, but fails in Chrome. After using Actions to handle the click button, it is working perfectly.

 Actions action = new Actions(_driver);
 action.MoveToElement(ElementName).Build().Perform();
 action.Click().Build().Perform();       

August 15, 2016

Fixed the issue: HttpWebRequest.GetResponse() throws 500 error

Today one of our automated tests failed. After looking into this issue, I noticed that in this test case, we need to verify the http status code of some links.

The interesting part is that one external link is always working, but HttpWebRequest.GetResponse() always returned the error code 500.

After doing some research, I added the code (Yellow) in our utility class. After running the test again, the test passed.

string url="https://www.XXX.com/";
         
HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create(url);

myWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; 


WebResponse myWebResponse = myWebRequest.GetResponse();

August 11, 2016

How to handle multiple windows in Selenium?

If new members work on automated tests via our Selenium test framework, the common question they have is how to handle the additional window popbox if we click the url in the current window ?

It is pretty easy.  Using the following C # code works perfectly.

                      var windows = _driver.WindowHandles;
                    _driver.SwitchTo().Window(windows[1]);

                      // do something such as Assertion.
                    _driver.Close(); 
                    _driver.SwitchTo().Window(windows[0]);

August 10, 2016

Selenium: How to add C# code to Disable Developer mode extensions in Chrome ?

Today, one automated test failed in Chrome. My Chrome version is Chrome 52.0.2743.116.


 After looking into this issue, I noticed that when running the test in Chrome using C# and Selenium , “Disable Developer mode extensions” popbox appeared all the time. That explained why the test failed.

After adding the following code in the file and running the test, “Disable Developer mode extensions” popbox disappears all the time.

  Namespace: using OpenQA.Selenium.Chrome;
  ChromeOptions options = new ChromeOptions();
  options.AddArgument("--disable-extensions");                    
 _driver = new ChromeDriver(options);

March 23, 2016

Selenium and C#: How to do mouse hover action in Selenium?

Today I wanted to verify the texts. The interesting part is that if I don’t do mouse hover action, Selenium WebDriver can’t return the texts. It returns empty string.

If I use the following code (Action-MoveToElement-Perform ) to do mouse hover action on the account menu in the site, I can verify the texts easily.  

Actions actions = new Actions(driver);
actions.MoveToElement(elementName);
actions.Perform();

Thread.Sleep(1000);

March 17, 2016

Fixed the issue in Selenium: An exception of type OpenQA.Selenium.WebDriverException occurred in WebDriver.dll but was not handled in user code

I am currently working on a new project where I need to write Selenium with C# to do the web automation in Visual Studio 2015.

Today after I rebooted my machine, I noticed that Firefox was removed. Therefore, I installed the new version of Firefox (45.0). After that, when running the tests, it caused the following Firefox Driver error, but it was working yesterday. 




I asked my test lead and he noticed that I installed the new version, but we still need to use Firefox 44.02.  After uninstalling Firefox 45.0 and installing Firefox 44.02, running the tests in Selenium passed.