I'm trying to do some coded UI tests with Visual Studio 2010 on my SharePoint 2010 site. A particular file in SharePoint launches my Silverlight application in a separate window. I've added the SilerlightUIAutomationHelper assembly as a reference in all my Silverlight projects that run this. This SHOULD allow me to record actions within it, but it pops up with an error message when I try to record inside my Silverlight app:
No Silverlight controls were detected. Verify that the application under test
is built using Silverlight assemblies with a version of 4.0 or greater and that
a reference to the Microsoft.VisualStudio.TestTools.Extension.SilverlightUIAutomationHelper.dll
assembly has been added to the project.
I'm running Silverlight 5.0, so that can't be the issue. I've also verified that the SilverlightUIAutomationHelper dll has made it into the xap package.
I've been able to successfully record these actions in SharePoint 2013/Visual Studio 2012 with this extension: http://visualstudiogallery.msdn.microsoft.com/28312a61-9451-451a-990c-c9929b751eb4
Any idea why this is happening? What can I do to fix it?
In order to do Coded UI tests in Silverlight 5 you need to use update the Coded UI automation helper from here: Visual Studio Gallery: UI Test Plugin for Silverlight The old one that ships with VS2010 works but only on SL4 and bellow.
SL5 was implemented a tad bit differently and it broke the Coded UI tests, therefore prompting devs to switch to VS2012 and the new UI Automation Plugin (as you have discovered).
Once you install the the UITestPluginForSilverlight.msi executable, you need to reference those assemblies in the Silverlight portion of your project (which you already have).
As far as I remember, and the reason why your Coded UI Tests broke in VS2010 but work in VS2012 is because the SL5 and SL4 UIMap.designer.cs files that are generated by the test recorders are not much compatible with each other.
SL4 recordings Generated with SL4 automation helper will not work with SL5 version of the AutiomationHelper. However SL5 Autiomation Helper will work with SL4 recordings if those recordings are generated by VS2012.
So to elaborate: When you use the recorder, it creates a UIMap file. The map file has three portions to it:
If you inspect the designer generated code behind file, you can actually figure out that the recorder generates a whole lot of code to find the controls and interact with them.
For each control the recorder discovers it declares an instance of the corresponding test/interaction object.
When declaring those objects the recorder defines a bunch of discoverable/searchable properties. The next time the playback executes it takes these properties and uses them to find the actual control.
Also, all controls have a parent, so the recorder mandatory specifies a parent UI element for each discovered control. For SL4 and SL5 the parents are as follows:
Constructor:
Search Properties:
A combo box with two items, each named "List Item" may be discovered by the following display names:
"List Item : 1" and "List Item : 2"
So long story short, the actual interaction objects generated by the recorders are different in SL4 and SL5. Meaning you can't take one UIMap.designer.cs and swap it with another. The test framework (and it's associated interaction objects used in the UIMap.designer.cs) are not binary compatible. That's why your playback can't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With