Share via


Extending Coded UI Tests and Action Recordings to Support Microsoft Excel

The testing framework for coded UI tests and action recordings does not support every possible user interface. It might not support the specific UI that you want to test. For example, you cannot immediately create a coded UI test or an action recording for a Microsoft Excel spreadsheet. However, you can create your own extension to the coded UI test framework that will support your specific UI by taking advantage of the extensibility of the coded UI test framework. The following topic gives an example of how to extend the framework to support the creation of coded UI tests and action recordings for Microsoft Excel. For more information about the platforms that are supported, see Supported Configurations and Platforms for Coded UI Tests and Action Recordings.

This section presents a coded UI test extension that can record and play back tests of Excel Worksheets. Each part of the extension is explained in this section and in the code comments for developers who want to create just such an extension.

Architecture Overview

UI Test Architecture

Download the Sample

The sample consists of four projects in the CodedUIExtensibilitySample.sln solution:

  • CodedUIextensibilitySample

  • ExcelCodedUIAddInHelper

  • ExcelUICommunicationHelper

  • SampleTestProject

To download the compressed project files, use the following Microsoft Web site.

Note

The Excel sample is intended for use with Microsoft Excel 2010. The sample may work with other versions of Microsoft Excel, but it is not currently supported.

Details about the Sample

The following sections provide information about the sample and its structure.

Microsoft Excel Add-in: ExcelCodedUIAddinHelper

This project includes an add-in that runs in the Excel process. See Sample Excel Add-In for Coded UI Testing for a brief overview of the add-in project.

For more information, see Walkthrough: Creating Your First Application-Level Add-in for Excel.

Excel UI Communication: ExcelUIcommunicationHelper

This project includes the IExcelUICommunication interface and the information classes that are used to pass data between the Coded UI Testing Framework and Excel. For more information, see Sample Excel Communicator Interface.

Coded UI Test Extension: CodedUIExentsibilitySample

This project includes the custom classes that are used in tests of an Excel worksheet. The code for each of these classes is fairly self-explanatory. However, we provide a short description of each custom class. For more information, see Sample Coded UI Test Extension for Excel.

Deploying Your Add-in and Extension

After you have created all projects and objects, run the provided CopyDrop.bat file as an administrator. This file copies the ExcelCodedUIAddinHelper DLL and PDB files to "%CommonProgramFiles%\Microsoft Shared\VSTT\10.0\UITestExtensionPackages\*.*", and the ExcelUICommunicationHelper DLL and PDB files to "%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies". You might have to adjust the exact copy paths, but no additional installation is required. On a 64-bit machine, use the 32-bit Visual Studio Premium command prompt to run the CopyDrop.bat file.

Testing Excel with the SampleTestProject

You can run the test in the provided test project which uses a specific version of Excel that you may not have, or create your own test project and record a test of your own. For more information, see How to: Create a Coded UI Test.

See Also

Tasks

How to: Create a Coded UI Test

Reference

UITestPropertyProvider

UITechnologyElement

UITestActionFilter

UITestExtensionPackage

Concepts

Testing the User Interface with Automated UI Tests

Best Practices for Coded UI Tests

Supported Configurations and Platforms for Coded UI Tests and Action Recordings