Share via


How to: Play Back a Web-Based Coded UI Test Using Firefox

You can create automated tests of the user interface (UI) known as coded UI tests. These tests provide functional testing of the UI and validation of UI controls. Coded UI tests let you test the functionality of user interface. Using the Microsoft Visual Studio 2010 Feature Pack 2, you can record UI actions on a website or a Web-based application and create coded UI tests. You can use Windows Internet Explorer to record the actions and then play back the tests using the Mozilla Firefox browser.

For more information about creating coded UI tests, see Testing the User Interface with Automated UI Tests or Walkthrough: Playing Back Coded UI Tests Using Firefox.

Warning

After you have completed the installation of Microsoft Visual Studio 2010 Feature Pack 2, if you want to use the Test Package for Mozilla Firefox, you must install and configure the Test Helper Extension for Mozilla Firefox. For more information, see How to: Install the Test Helper Extension for Mozilla Firefox.

Warning

You can only use the Firefox browser to play back the coded UI tests. Recording coded UI tests on websites and Web applications by using the Firefox browser is not supported.

Add Property to Play Back Using Mozilla Firefox

  1. Verify that you have installed Microsoft Visual Studio 2010 Feature Pack 2 and the Test Helper Extension for Mozilla Firefox. Information about installation is included in the introduction.

  2. Verify that you have installed Firefox version 3.5 or 3.6. Run Firefox at least one time using your user credentials.

  3. Create a coded UI test on a Web-based application or a website using Windows Internet Explorer.

    For more information, see Walkthrough: Creating, Editing and Maintaining a Coded UI Test or Walkthrough: Playing Back Coded UI Tests Using Firefox.

  4. In the CodedUITest1.cs file, locate the MyTestInitialize() method which uses the TestInitializeAttribute uncomment the code and add the CurrentBrowser property with its value assigned as “FireFox” as shown in the following code:

    Tip

    Optionally, instead of adding the BrowserWindow property, you can create an environment variable called CodedUITestCurrentBrowser that has a value of “Firefox” and then restart Visual Studio.

    ////Use TestInitialize to run code before running each test 
            [TestInitialize()]
            public void MyTestInitialize()
            {        
            //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            //    // For more information on generated code, see https://go.microsoft.com/fwlink/?LinkId=179463
                BrowserWindow.CurrentBrowser = "Firefox";
            }
    
    ' Use TestInitialize to run code before running each test
        <TestInitialize()> Public Sub MyTestInitialize()
            '
            ' To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            ' For more information on generated code, see https://go.microsoft.com/fwlink/?LinkId=179463
            '
            BrowserWindow.CurrentBrowser = "Firefox"
    
    
        End Sub
    

    Tip

    If you have multiple versions of Firefox installed on your system, you can choose a specific version using the Browser.CurrentBrowser variable. For example, “Firefox 3.5.7 (en-US)”. For more information, see Recording Tests Using Windows Internet Explorer and Playing Back Using Mozilla Firefox.

    For more information about how to use the TestInitialze() attribute, see How to: Generate a Coded UI Test by Recording the Application Under Test.

  5. In the CodedUITest file, locate the coded UI test method. Right-click it and select Run Tests.

    -or-

    On the Test menu, select Windows and then click Test View.In Test View, select CodedUITestMethod1 under the Test Name column and then click Run Selection in the toolbar.

    The coded UI test should run using Firefox.

See Also

Tasks

Walkthrough: Playing Back Coded UI Tests Using Firefox

Concepts

Testing the User Interface with Automated UI Tests

Other Resources

Recording Tests Using Windows Internet Explorer and Playing Back Using Mozilla Firefox