Using Different Web Browsers with Coded UI Tests
Coded UI tests can automate testing for web applications by recording your tests using Internet Explorer. You can then customize your test and play it back using either Internet Explorer or other browser types for these web applications.
Visual Studio Ultimateor Visual Studio Premium with Visual Studio 2012 Update 4 (or a later version of Visual Studio Ultimate)
Microsoft Windows 7
Microsoft Windows 8
Microsoft Windows Server 2008 R2 SP1
Web browser versions:
Windows Internet Explorer 9
Windows Internet Explorer 10
For supported versions of Mozilla Firefox and Google Chrome, go here
What’s supported across all web browsers?
Add custom code for controlling features such as properties, search, and playback waiters.
Pop-ups and dialog boxes
Search resilience (using smart match) and performance improvements
Why should I use coded UI tests across multiple web browser types?
By testing your web application using a variety of web browser types, you better emulate the UI experience of your users who may run different browsers. For example, your application might include a control or code in Internet Explorer that is not compatible with other web browsers. By running your coded UI tests across other browsers, you can discover and correct any issue before it impacts your customers.
How do I record and play back coded UI tests on web applications using the supported web browsers?
Recording: You must use the Coded UI Test Builder to record your web application test using Internet Explorer. You can optionally add validation and custom code for the tested controls using a predefined set of properties as you would normally do for coded UI tests. For more information, see Verifying Code by Using Coded User Interface Tests.
You cannot record coded UI tests using Google Chrome or Mozilla Firefox browsers.
Play back with Internet Explorer: When no browser is explicitly specified, tests will run on Internet Explorer by default. You can explicitly state the browser to be used by setting the BrowserWindow.CurrentBrowser property in your test code. For Internet Explorer, this property should be set to IE or Internet Explorer.
Play back with non-Internet Explorer web browsers: To play back on non-Internet Explorer web browsers, change BrowserWindow.CurrentBrowser property in your test code to either Firefox or Chrome.
To play back tests on non-IE web browsers, you must install the Selenium components for Coded UI Cross Browser Testing.
Installing Selenium components
On the Tools menu, choose Extensions and Updates.
In the Extension and Updates dialog box, search for Selenium components for Cross Browser Testing.
Highlight the extension and choose Download.
You can also download the Selenium components for Coded UI Cross Browser Testing from here.
For more information about creating and using coded UI tests, see Creating Coded UI Tests.
To enable debugging your web application, you must complete the following configuration options:
Enable Just My Code:
On the Tools menu, choose Options and then choose Debugging.
Select Enable Just My Code.
Disable CLR exceptions:
On the Debug menu, choose Exceptions.
For Common Language Runtime Exceptions, uncheck User-unhandled.
- I don't see the option to change BrowserWindow.CurrentBrowser in the coded UI test.
You might be using a version of Microsoft Visual Studio 2012 that does not support coded UI tests using various web browsers. To use such coded UI tests, you must use Visual Studio Ultimate with Visual Studio 2012 Update 4 or a later version of Visual Studio Ultimate.
What else should I know?
Apple Safari web browser is not supported.
The action of starting the web browser must be part of the coded UI test.
If you have a web browser already open and you want to run steps on it, the playback will fail unless you are using Internet Explorer. Therefore, it is a best practice to include the startup of your web browser as part of your coded UI tests.
Automating browser specific based UI actions such as maximize, minimize and restore is not supported.
You can configure the output to include screenshots in the coded UI logs. To do so, you need to set some configuration settings in the QTAgent32.exe.config file. By default, this file is installed in the following location:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE
Set the following values:
EqtTraceLevel in the system.diagnostics section.
<add name="EqtTraceLevel" value="4" />
By setting the value to be 3 or higher, screenshots are taken for each action. When the value is set to either 1 or 2, screenshots are taken for error actions only.
For more information, see Analyzing Coded UI Tests Using Coded UI Test Logs.