Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?

Archives
Steve Trefethen Steve's RSS Feed Subscribe or via email
What's this?
Contact me Send mail to the author(s)
About Me
View my LinkedIn profile

Add to Google
Subscribe with Bloglines
MCP Microsoft Certified Professional

Falafel Software
ActiveFocus Project Management Solution by Falafel Software
Online or OnSite TestComplete Training
Blogroll
Recent Comments
My Online Tools
Stats
Total Posts: 441
This Year: 46
This Month: 2
This Week: 0
Comments: 1526
Tags
Disclaimer
The posts on this weblog are provided �AS IS� with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer�s view in any way.
 Tuesday, April 22, 2008

If you're a Clive Cussler fan you'll enjoy this...

Posted @ 7:50AM by Steve Trefethen

Categories: For fun | Recommended

Tags:  | 

I’m a big Clive Clusser fan and I stumbled into this article by Joshua Davis in Wired through Barry Kelly's shared Google Reader items. It’s been sitting in a tab in my browser for days now and I’ve read it a few times and I keep getting drawn back to it sort of like I did with Into Thin Air yet another good real life story.

Thanks Barry!

Do you have a link blog or share links via Reader?

 Thursday, April 03, 2008

My TEDTalks list

Posted @ 1:00PM by Steve Trefethen

Categories: Recommended

Tags:

I’ve blogged about a few TEDTalks I’ve enjoyed and finally decided to post my entire list of favorites, 15 and counting.

What are your favorites?

 Tuesday, July 31, 2007

Automated testing of ASP.NET web applications using Selenium

Posted @ 1:06AM by Steve Trefethen

Categories: .NET | AJAX | ASP.NET | Automation | Continuous Integration | Firefox | IDE | Open Source | Quality | Recommended | Testing | Tools

Tags:  |  |  |  |  |  |  |  |  |  |  | 

Lately, I've been focused on Web Application testing frameworks and I've been looking at a number of different options and having varying degrees of success. That is, of course, until I started looking at Selenium after Lino mentioned it to me and I'm very impressed. Selenium is an open source project with multiple tools designed for testing web applications. Selenium includes:

  • Selenium IDE an add-on to Firefox use for recording test scripts
  • Selenium RC (Remote Control) a Java server used for execution of test scripts
  • Selenium Core client side testing support for web applications added directly to your application
All of these are interesting in their own right so be sure to look closely at each piece.

Selenium IDE

Selenium IDE
The Selenium IDE is a non-modal dialog add-on for Firefox that supports Selenium test development. In fact, it's more than fair to call this single dialog an IDE because it fully supports recording, development and debugging of test scripts. Additionally, it can format test scripts in any of the following for use with Selenium RC:
  • HTML
  • Java
  • C#
  • Perl
  • PHP
  • Python
  • Ruby

A Selenium test script consists of a series of Commands which have a Target and optionally a Value. For example, browsing to a web page using Selenium consists of the following:

Command: open
Target: http://localhost/myapp

To click on a link titled "About" on a page the Command might look like this:

Command: clickAndWait
Target: link=About

This will initiate the click and wait until the new page is done loading. There are literally hundreds of commands to choose from covering input (both keyboard and mouse), control manipulation, drag/drop, evaluation, verification, waiting, browser manipulation and just about anything else you'll need.

If you've done any UI testing at all you're familiar with the challenge of manipulating a UI programmatically in a manner independent from of the size, position or location of the control you're trying to manipulate. Selenium solves this problem using XPATH and providing the ability to locate controls based on XPATH expressions alleviating the need to hard code HTML tag structure into a test script. This is particularly crucial for ASP.NET testing since the runtime mangles the ID attributes of rendered tags. For example, the ASP.NET runtime may render ID attributes that look like:

id="ctl00_cphContents_gridMaint_DataGrid"

Finding this control using an XPATH expression can be simplified to something like this:

//table[contains(@id, "gridMaint")]

In the event the nesting of the DataGrid changes the script will continue to function properly as long as table's ID contains the text "gridMaint".

Example of using the Find button on the Selenium IDE

Notice the link is highlighted in the browser

Playing back tests using Selenium TestRunner

The Selenium IDE has a toolbar button that will launch a feature called TestRunner which allows you to playback your tests using controls hosted in an IFRAME inside your browser. Here's what it looks like:

Selenium TestRunner

You can playback your entire test from right within your browser. It's like having the IDE built right into your application.

Selenium RC

Next, is Selenium RC which is a Java server application used execute Selenium tests and drive a browser instance through AJAX communication with the browser. To start Selenium RC simply execute the following from a command prompt:

java -jar selenium-server.jar -interactive

Since I'm focused on .NET I'll discuss the C# approach. Once you've recorded and debugged your test you can capture it as C# and compile it into an NUnit compatible assembly where upon execution it will drive Selenium RC to manipulate the web application through a browser instance running on your desktop. Here is an example of the above recorded test in C#:

1 using System; 2 using System.Text; 3 using System.Text.RegularExpressions; 4 using System.Threading; 5 using NUnit.Framework; 6 using Selenium; 7 8 namespace SeleniumTests 9 { 10 [TestFixture] 11 public class NewTest 12 { 13 private ISelenium selenium; 14 private StringBuilder verificationErrors; 15 16 [SetUp] 17 public void SetupTest() 18 { 19 selenium = new DefaultSelenium("localhost", 4444, "*firefox", 20 "http://localhost:4444"); 21 selenium.Start(); 22 verificationErrors = new StringBuilder(); 23 } 24 25 [TearDown] 26 public void TeardownTest() 27 { 28 try 29 { 30 selenium.Stop(); 31 } 32 catch (Exception) 33 { 34 // Ignore errors if unable to close the browser 35 } 36 Assert.AreEqual("", verificationErrors.ToString()); 37 } 38 39 [Test] 40 public void TheNewTest() 41 { 42 selenium.Open("/selenium-ide/"); 43 selenium.Click("link=About"); 44 selenium.WaitForPageToLoad("30000"); 45 } 46 } 47 } 48

Generation of NUnit compatible tests is great because it makes it really easy to incorporate Selenium test suites into a continuous integration environment like CruiseControl.NET.

Conclusion

If you're in need of a web application testing framework you owe it to yourself to check out Selenium. I'd go so far as to say if you're doing doing any web related development and you're not already using Selenium you should stop right now and go download it. Here are there RSS feeds.

After playing with Selenium for about an hour I was easily able to:

  • Record tests against a RIA
  • Build a C# NUnit compatible assembly to drive Selenium RC
  • Integrate the tests into an automated build using CruiseControl.NET

Since then I've been able to really dig in and accomplish a lot of work in a very short period of time. The next step is to build up a nice battery of tests and dig into NCover to help figure out where the holes are.

Lastly, I just want to tip my hat to the ThoughtWorks and volunteers and supporters of the Selenium project. Kudos for such a great framework!

 Sunday, May 13, 2007

Using Microsoft's SyncToy for managing file backups to an external drive

Posted @ 11:10PM by Steve Trefethen

Categories: Photography | Recommended | Tools

Tags:  |  | 

Microsoft SyncToy

If you've been reading my blog lately, you know I've been working to get my backup situation improved particluarly when it comes to DV tapes and photos. I've been using $g(Microsoft's SyncToy), one of the free Microsoft Power Toys for Windows XP and I have to say it works fairly well and supports scheduling backups with Windows Task Scheduler using the -R command line switch for selecting particular file groups. I wish Microsoft would release the source code to apps like this so they could be picked up by the development community and further enhanced rather than releasing them with an unknown future. Prior using SyncToy I used a batch file and xcopy so to having a UI to configure targets source/destination directories is nice.

What do you use for syncing files/directories?

 Wednesday, March 07, 2007

Fixing ASP.NET error: The state information is invalid for this page and might be corrupted.

Posted @ 9:48PM by Steve Trefethen

Categories: ASP.NET | dasBlog | Hosting | Recommended

Tags:  |  |  | 

I've been running dasBlog for several months now and I'd been having problems with my login timing out very quickly. I added a HealthMonitoring section to my web.config so as to get email notifications when errors occurred. Right away I noticed that simply refreshing the browser could trigger an authentication error like:

Forms authentication failed for the request. Reason: The ticket 
supplied was invalid.

I Googled for ways to resolve these errors and found this article from my hosting provider no less. I then used the online machinekey generator and added it to my web.config and my dasblog login errors were history as well as the invalid viewstate problems! Basically, the key used for encrypting the authentication information was getting changed between request as a result of either the server or the ASP.NET worker process being recylced.

<providerplug>
You can probably tell I really like DiscountASP.NET they've got a great options, a great control panel (which is frequently enhanced) and they have some great technical staff who post to their support forums. I've gone so far as to join their referral program, so if you sign up please use the link above which includes my referral ID to let them know I sent you!
</providerplug>

 Friday, February 16, 2007

Recommended: delphi.about.com's Delphi Programming RSS feed

Posted @ 11:34AM by Steve Trefethen

Categories: Delphi | Recommended

Tags:  | 

If you're a Delphi developer I'd highly recommend subscribing Zarko Gajic's Delphi Programming RSS feed from delphi.about.com. It's a little unfortunate that the XML icon on the site doesn't link you directly to the Feed but rather a subscription page that starts with an email subscription form which confused me for a second until I realized that the RSS info was at the bottom.

Anyway, Zarko cranks out useful Delphi tips seemingly every day of the week so you're bound to see something that's useful to you. I've linked to his column in the navigation section of the right hand sidebar of my blog.

Keep up the great work Zarko!