Coded UI Test not finding SilverlightUIAutomationHelper assembly
Asked Answered
B

1

8

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?

Birgitbirgitta answered 3/4, 2013 at 13:13 Comment(4)
You're using a recent Internet Explorer as suggested on the extension page you linked to?Oatis
@Oatis Yea, I've tried this with IE8 & 9Birgitbirgitta
some times coded UI tests are weird try do a manual click on the silver-light control while its looking for the controls to see if it finds it.Metry
Do you have feature pack 2 installed ?Tinhorn
Y
4

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:

  1. XML Listing of all the recorded methods
  2. Designer Generated Code Behind partial class.
  3. A user partial class.

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:

  • Browser Window
  • HTML Page
  • Div (holding the silverlight runtime)
  • SL Object (SL Runtime plugin)
  • Main SL UI Element (usually the squigly buzy indicator)
  • Navigation Frames
  • Internal Pages
  • Controls

Constructor:

  1. Parent Control/Interaction Object

Search Properties:

  1. Page Title: The total string that is rendered by the browser's window title.
  2. Instance Number: (starts from 1 for lists... which is weird)
  3. Control Id: (defined by the Name or x:Name xaml attributes)
  4. Display Name: This is iffy for combo box/list elements as it works by combining whatever is rendered in the combo box/list element item combined with the instance number of that item: for example:

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"

  1. Any combination and permutation of search attributes (you can look them up).

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.

Yoakum answered 24/9, 2013 at 18:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.