Coded UI and Silverlight… simple

In fact it took me an appallingly long time for the penny to drop, but all the clues are in the generated code when you use the Test Builder.

So here is a picture where [1] is the BrowserWindow… and [6] is one of the Silverlight controls:

CodedUiHandNotes01

This is the single (text) control I’m testing:

CodedUiHandNotes02

These are that control’s properties in Silverlight:

CodedUiHandNotes03

In the generated test (i.e. Record and Playback, [1] is the hand-added launch of the browser, [2] is the call to the test class that the generator put there:

CodedUiHandNotes04

The content of that method, which shows the cascaded calls:

CodedUiHandNotes05

The pattern used at each of the levels:

CodedUiHandNotes06

The classes and constructors where relevant for each of those elements (this is a generated file which will be rebuilt the next time you define er stuff, but it gives you a good template):

CodedUiHandNotes08 CodedUiHandNotes09 CodedUiHandNotes10 CodedUiHandNotes11 CodedUiHandNotes12 CodedUiHandNotes13

and a very trivial proof that it works… of course it does, as it’s basically the Record and Playback:

CodedUiHandNotes14 CodedUiHandNotes15

 

I have pasted a version of the Coded UI here…

http://pastebin.com/NUgg4m1R

, and a version of the SLUT here (XAML):

http://pastebin.com/EMF186j9

, and the code behind:

(remember the need to include this:

using Microsoft.VisualStudio.TestTools.UITest.Extension.SilverlightUIAutomationHelper;

)
http://pastebin.com/UQhmJV6w

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s