Search This Blog

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

}