Answer 2
1) The links to that sample excel plugin at the top of the page are broken. The link at the bottom of the page never worked for me. I used this download http://code.msdn.microsoft.com/excelCUITechProv
2) I'm using Office Professional Plus 2010
In this sample excel plugin the playback selects cell B2 and types Hello World. The only way I can get this test to pass is by setting the focus on the Cell B2 object.
So the test fails unless I add the following code:
uISheet122Cell.SetFocus();
Without the above code, the test fails and gives the following exception and error stack trace:
Test method SampleTestProject.CodedUITest1.CodedUITestMethod1 threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyValue(String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetProperty(String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyInternal[T](String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_BoundingRectangle()
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.CaptureImage()
Microsoft.VisualStudio.TestTools.UITesting.Playback.CaptureScreenShot(UITestControl control)
Microsoft.VisualStudio.TestTools.UITesting.Playback.GetUITestControlString(UITestControl control)
Microsoft.VisualStudio.TestTools.UITesting.Playback.AddUITestControlDescriptionToException(SystemException exception, IPlaybackContext context)
Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, IPlaybackContext context)
Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String actionName, UITestControl uiControl)
Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String actionName, Object parameterValue, UITestControl uiControl)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyValue(String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetProperty(String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyInternal[T](String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_Enabled()
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetEnabledWithoutWFR()
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlEnabled(Int32 millisecondsTimeout)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SendKeys(String text, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
Microsoft.VisualStudio.TestTools.UITesting.Keyboard.SendKeysImplementation(UITestControl control, String text, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
Microsoft.VisualStudio.TestTools.UITesting.Keyboard.SendKeysImplementationWrapper(UITestControl control, String text, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
Microsoft.VisualStudio.TestTools.UITesting.Keyboard.SendKeys(UITestControl control, String text, ModifierKeys modifierKeys)
SampleTestProject.UIMap.ClickB2andtypeHelloWorld() in C:\Users\seans\Documents\Visual Studio 2010\Projects\CodedUITestOfExcel\SampleTestProject\UIMap.Designer.cs: line 69
SampleTestProject.CodedUITest1.CodedUITestMethod1() in C:\Users\seans\Documents\Visual Studio 2010\Projects\CodedUITestOfExcel\SampleTestProject\CodedUITest1.cs: line 31
Here also is the test log:
E, 312, 30, 2010/07/20, 10:08:08.978, 164781546449, QTAgent32.exe, GetClassName for handle 198634 failed
E, 312, 30, 2010/07/20, 10:08:08.979, 164781549998, QTAgent32.exe, GetClassName for handle 198634 failed
GetClassName for handle 198634 Writelineed
E, 312, 30, 2010/07/20, 10:08:08.986, 164781564642, QTAgent32.exe, GetClassName for handle 198634 failed
E, 312, 30, 2010/07/20, 10:08:08.996, 164781590159, QTAgent32.exe, GetClassName for handle 198634 failed
E, 312, 30, 2010/07/20, 10:08:09.043, 164781698709, QTAgent32.exe, Window 198634 not responding. Last Win32 error 2
E, 312, 30, 2010/07/20, 10:08:09.049, 164781712222, QTAgent32.exe, GetClassName for handle 198634 failed
E, 312, 30, 2010/07/20, 10:08:09.063, 164781745399, QTAgent32.exe, Window 198634 not responding. Last Win32 error 2
E, 312, 30, 2010/07/20, 10:08:09.063, 164781745895, QTAgent32.exe, GetClassName for handle 198634 failed
W, 312, 30, 2010/07/20, 10:08:09.877, 164783647934, QTAgent32.exe, IEDOM : StopSession of the plugin called before StartSession
W, 312, 30, 2010/07/20, 10:08:09.877, 164783648077, QTAgent32.exe, UIA : StopSession of the plugin called before StartSession
3) Event Viewer when uISheet122Cell() is commented out:
The test fails here
Application Error:
Application: CodedUITestBuilder.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Microsoft.VisualStudio.TestTools.CodedUITest.Controls.UIControlLocator.UIControlFinder.PlaybackThreadproc()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
.NET Runtime:
Application: CodedUITestBuilder.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Microsoft.VisualStudio.TestTools.CodedUITest.Controls.UIControlLocator.UIControlFinder.PlaybackThreadproc()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
Code viewer when uISheet122Cell.SetFocus() is uncommented and then try recording additional tests using the
coded UI Test Builder:
Application Error:
Faulting application name: CodedUITestBuilder.exe, version: 10.0.30319.1, time stamp: 0x4ba21143
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x0596b754
Faulting process id: 0x9c
Faulting application start time: 0x01cb28253b8386f7
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\CodedUITestBuilder.exe
Faulting module path: unknown
Report Id: 7d07cf95-9418-11df-9e7e-0023ae6ec623
.NET Runtime:
Application: CodedUITestBuilder.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Microsoft.VisualStudio.TestTools.CodedUITest.Controls.UIControlLocator.UIControlFinder.PlaybackThreadproc()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()