3. Introducing Sample Excel Extension
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 –
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. |
|
ExcelActionFilter |
An action filter (aggregation rule) specific to Excel. This class implements UITestActionFilter. |
|
ExcelPropertyProvider |
The property provider for Excel. This class implements UITestPropertyProvider. |
|
ExcelExtensionPackage |
The package entry point. This is similar to HelloWorldPackage class covered in 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.
Comments
Anonymous
July 07, 2010
I'm having problems getting this addon to run. I'm in VS 2010 Premium and running office 2010. I got a successful build and I ran the copy.bat and I still cannot select and individual cell.Anonymous
July 12, 2010
Sorry for late reply. For some reason, my blog settings got messed up and I had trouble login in. In general, the Coded UI Test forum (social.msdn.microsoft.com/.../threads) is better place to post your questions as that is monitored by many folks & you will get faster response. This sample was developed with Excel 2007 but I know folks have got it working for Excel 2010 with minor modification which I don't remember. See if you can debug the problem. Thanks, GautamAnonymous
January 14, 2011
I am having problem building the solution on namespace Microsoft.Office.Tools.Excel.Extensions.Anonymous
February 11, 2011
This could be because you don't have Visual Studio Tools for Office on your machine.Anonymous
February 28, 2011
Can you please suggest me how to make it work with Office 2010? I ran copy.bat file and still was not able to identify the cells in excel.Anonymous
March 02, 2011
@Kranthi - Did you open the solution in VS and build it?Anonymous
May 09, 2011
The comment has been removedAnonymous
May 09, 2011
Difficult to say based on just this info. Since the source code is there and this blog covers how to debug extensions, I suggest you give it a shot. Thanks.Anonymous
July 05, 2011
Do you have any sample to automation java applicationsAnonymous
July 10, 2011
@chetan - NoAnonymous
November 13, 2011
I am able to build the add-in solution and copied the files using copydrop.bat. When I tried use the recorder on excel, i am getting this error "Failed to connect to an IPC Port: The system cannot find the file specified." Please help me in solving this.Anonymous
November 29, 2011
Murali - Are you still facing this? Try running the plugin once with VS.Anonymous
June 27, 2012
The comment has been removedAnonymous
July 02, 2012
This error is coming when i am running test case... System.ArgumentException: The following is not a valid technology name: Excel. To search for a control, you must specify a valid technology name. Parameter name: TechnologyNameAnonymous
July 08, 2012
@Ankit - The plugin has not been registered properly. Please run it from VS once and try. If it still does not work for you, I suggest trying MSDN forum for Coded UI Test.Anonymous
October 22, 2012
Is there any Copyright/license requirement for using this code? Please let me know. ThanksAnonymous
October 29, 2012
@Adi - This is sample code and not supported by MS or me. You can use this to build your own plugin.