Showing posts with label testing. Show all posts
Showing posts with label testing. Show all posts

Wednesday, April 15, 2009

Silverlight Automated UI Testing

Working with alot of larger clients at IdentityMine we frequently work with teams that use automated testing and deployment systems. I did a post last year on deployment with msbuild and build environment deployments etc and today I'd like todo a quick post on wiring up a Silverlight application for automated UI testing. This is a great way to tied into existing test structures but keep in mind there is a Unit test framework off MSDN that is a great place to start.

http://code.msdn.microsoft.com/silverlightut/

and

http://weblogs.asp.net/scottgu/archive/2008/04/02/unit-testing-with-silverlight.aspx

So quick and dirty this method is kind of a hack to expose bits to existing web testing systems that can only talk to the DOM. with that... I'm going to focus on showing you alot of code...

To start with we have this simple application using this xaml keeping in mind I excluded the extrensous stuff...

<grid>
<grid.columndefinitions>
<columndefinition>
<columndefinition>
<columndefinition>
</Grid.ColumnDefinitions>
<textbox name="inputhere" height="30">
<button name="Btn1" content="process input" click="Button_Click" column="1" height="30">
<textbox name="Output" height="30" column="2">
</grid>

and in the code we add the following C#


private string ProcessString = "complete with [{0}]";

private void Button_Click(object sender, RoutedEventArgs e)
{
Output.Text = string.Format(ProcessString, inputhere.Text);
}

this works great but pretend it is much more complicated... So then we add the following code to our code behind...:

[ScriptableMember]
public void SetTextField(String InputValue)
{
inputhere.Text = InputValue;
}

[ScriptableMember]
public void ClickButton()
{
Button_Click(new object(), null);
}

[ScriptableMember]
public string GetValue()
{
return Output.Text;
}

and then we add the following to our page constructor:


HtmlPage.RegisterScriptableObject("MainPage", this);

and we add this #include er I mean 'using' statement:

using System.Windows.Browser;

from here we have exposed the key elements so any testing system that can talk to the Browser DOM can then wire up to what appear at JavaScript objects like this:

//simulates input:
top.document.getElementById('Silverlight1').content.MainPage.SetTextField("test");

// simulates a click
top.document.getElementById('Silverlight1').content.MainPage.ClickButton();


//gets a value.
alert( top.document.getElementById('Silverlight1').content.MainPage.GetValue() );

I know quick and dirty but now our automated UI web app infrastructure can 'test' our Silverlight application easily.

Wednesday, January 21, 2009

Microsoft Tag

Here is an interesting if only vaguely connected to Silverlight bit from Microsoft...

Microsoft 'Tag'

Personally I could do without the colors but is an interesting idea that allows these computer read tags for embedding information on a page, or email etc. Something like an ubber UPC. In silverlight I can see some uses such as on crossfader I could have a tag for each artist on the back of media tiles. but maybe only if the tags work with gray scales...

http://tag.microsoft.com/

Thursday, January 3, 2008

Silverlight on the iPhone

don't get to excited Silverlight wasn't running ON the iphone but we did manage to get a silverlight app servered up from an iphone... So we thought we would have some fun and install an entire web site on an iphone, install it on our network in the data center and for extra special fun we pointed a high end web stress tool at the phone...

I was surprised to see that the phone for the first 3 minutes of the test was doing well with well over 163 concurrent users at a time on the site but at 16971 hits it melted...

http://www.hackingsilverlight.net/samples/iPhone/iphone.JPG
http://www.hackingsilverlight.net/samples/iPhone/IPhoneWebServer.jpg
http://www.hackingsilverlight.net/samples/iPhone/MVI_8003.AVI
http://www.hackingsilverlight.net/samples/iPhone/Site.jpg

as cool as this is Devin did manage to get his iphone recovered but it took some doing. currently though apache is dead and Devin is trying to get it running again...

Saturday, December 22, 2007

Full Length Movie Vie Silverlight

I'm ashamed to admit that I contributed in any way to this project... mind you I liked the Movielink team but the content is really really offesive in my opinion but the fact is that this is the first full length feature streamed via Silverlight to the masses. The player itself is straight forward and we un covered a few issues on the mac apprently in the underlying media stack in Silverlight but none the less a bug where about half way through the movie the sounds slowly gets upto a second off from the video... otherwise it works great :) if you must, you can check it out at:

http://blockbuster.jackassworld.com/

Wednesday, December 5, 2007

Silverlight Performance Testing

So it seems that alot of shops I run into as of late seem not to have done stress testing before... I know that this can't be the case normally but just in case I thought I would post something about pref testing silverlight.

With regard to Silverlight we need to break out pref into two areas. The abiltiy of the hosting infrastructure to server up component parts and do server side processing and then the how well the 'clientside' Silverlight application performs locally on any given client and browser combination. In most cases there would never ever be more then one instance of the application running side by side on any given client.

To do stress testing you can download something free like the MS Stress tool and record some nice test scripts and have a go at your server. Basically your hitting the box, filling informs and or clicking on links and the like and the tool uses that to simulate what your are doing but much faster to the point of failure on the server.

You can download the MS Stress Tool at:

http://www.microsoft.com/downloads/details.aspx?FamilyID=E2C0585A-062A-439E-A67D-75A89AA36495&displaylang=en

but there are a number of other tools such as :

http://jakarta.apache.org/jmeter/

that basically do the same thing.

Anyway when it comes to testing the client it is a matter of having a Mac and PC and all the browsers installed and then opening it up and testing everything. If the silverlight application is following the best practices such as those listed in the last post then it should be good and you can track down anything else on individual testing.

With that you should be armed to start doing some Silverlight perf testing.