I was putting together a demo of cross browser Coded UI testing with Visual Studio 2012 and ran into a minor problem. Hopefully this post will save you some time.
I grabbed the very helpful Visual Studio 2012 Application Lifecycle Management Virtual Machine and Hands-on-Labs / Demo Scripts from Brian Keller and installed Chrome, FireFox and the Selenium components for Coded UI Cross Browser Testing from the Visual Studio Gallery.
After that, one line of code can make your Coded UI tests run on a different browser. For example, just stick this line at the beginning of your test method:
BrowserWindow. CurrentBrowser = “chrome”;
More details here: Using Different Web Browsers with Coded UI Tests
The problem I ran into was that the Selenium Components installer failed, which seems to be a reasonably common issue due to access permissions, but helpfully Microsoft provide the simple steps to manually install what is needed.
1. Download chrome driver from:
http://chromedriver.googlecode.com/files/chromedriver_win_26.0.1383.0.zip
2. Download selenium dot net bindings from:
http://selenium.googlecode.com/files/selenium-dotnet-2.29.1.zip
3. Right click on the downloaded zip files.
4. Select "properties".
5. Under "General" tab, click on the "Unblock" button.
6. Now unzip both the files and copy the contents to the following path (for the selenium-dotnet 2.29.1 binaries, copy the contents of net40 folder):
"%ProgramFiles%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 32 bit machines)
"%ProgramFiles(x86)%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 64 bit machines)
On the 64 bit VM I unzipped the contents of the zip files into the “Cross Browser Selenium Components” folder and started my test but received the following error:
Test Method CodedUITestProject1.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException:
The playback engine could not find the selenium binaries required to run cross browser coded ui tests. This may be because the Selenium .Net bindings and the Selenium Chrome driver are not installed or an older version of the Selenium Components Installer was used. For more information about installing the binaries, see http://go.microsoft.com/fwlink/?LinkID=267598
The important line in the manual installation instructions that I’d failed to follow was:
for the selenium-dotnet 2.29.1 binaries, copy the contents of net40 folder
So, to resolve the problem, simply copy the contents of the “net40” sub-folder into the “Cross Browser Selenium Components” parent folder
Happy testing.
Cheers,
Richard
.