This is the third post in this series on the extensibility of Coded UI Test. Before reading this, you should read the previous posts of this series to better understand this post.

In this and next few posts, I will explain a sample extension that we have for Microsoft Excel. The worksheet (Grid like) control of Excel is a custom control and the cells in this control are not visible to Coded UI Test by default. The sample extension attached to this post uses the extensibility that I have mentioned in this series to make the cells inside the Excel Worksheet region visible to Coded UI Test as control with customized properties. Before continuing further, see the demo video of this extension in action –

To play with the sample, copy it locally and do a clean build. Use the CopyDrop.bat or refer step 5 in the blog 2 of this series to deploy the sample.

Now, let me explain the high level architecture and components of this extension. The architecture looks like –

image

The sample has 3 modules –

  • Excel Extension (Microsoft.VisualStudio.TestTools.UITest.Sample.ExcelExtenision.dll) – This is the extension using the Coded UI Test extensibility APIs. We will discuss this in detail.
  • Excel Add-in (Microsoft.VisualStudio.TestTools.UITest.Sample.ExcelAddin.dll) – This is an Excel add-in written using Visual Studio Tools for Office (VSTO). This add-in resides in Excel process and uses Excel object model to get information required by Coded UI Test. The code here is simple and not exactly relevant in understanding the Coded UI Test extensibility. Hence I will not go into the details of this module – the code is well commented and you will be able to follow it.
  • Excel Communicator (Microsoft.VisualStudio.TestTools.UITest.Sample.ExcelCommunication.dll) – The Excel Extension residing in Coded UI Test process communicates with Excel Add-in in Excel process using .NET Remoting. This module is just the interface definition for this communication.

The below table dives into Excel Extension at class\file level –

Class(es)

Description and use

Detail in blog

ExcelTechnologyManager, ExcelElement, ExcelWorksheetElement and ExcelCellElement

The main classes in this extension related to implementing the technology adapter for Excel. The ExcelTechnologyManager implements UITechnologyManager and other classes implement UITechnologyElement.

Blog 4 of this series

ExcelActionFilter

An action filter (aggregation rule) specific to Excel. This class implements UITestActionFilter.

Blog 6 of this series

ExcelPropertyProvider

The property provider for Excel. This class implements UITestPropertyProvider.

Blog 5 of this series

ExcelExtensionPackage

The package entry point. This is similar to HelloWorldPackage class covered in Blog 2 of this series.

Blog 2 of this series

ExcelCommunicator

Singleton instance to manage the .NET Remoting interface that is used to communicate with Excel Add-in.

-

Utilities

Various simple utilities and PInvoke definitions.

-

The sample is a basic sample for Excel support and is in no way near complete. The sample should be used for understanding the extensibility concepts and not as the real support for Excel.

The complete source code for this sample is here.

Proceed to blog 4 of the series to understand the code for this sample.