AOP, NUnit and Selenium: clever screenshots of failures

Last week I did struggle finding out why a test was failing only on our Cruise box, only in the Cruise build. I wanted to get a screenshot of each failing tests, and I think I found a clever solution: aop. We already use PostSharp on our code base for logging, transaction demarcation and hibernate session support, so I wrote a simple annotation for our acceptance tests:
using System;
using PostSharp.Laos;

namespace Web.UI.AcceptanceTests
{
        [Serializable]
        public class ScreenCaptureAttribute : OnExceptionAspect
        {
                public override void OnException(MethodExecutionEventArgs eventArgs)
                {
                        SeleniumManager.Selenium.CaptureScreenshot(string.Format("C:\\{0}.jpg", eventArgs.Method.Name));
                }
        }
}
Every time a test will throw an Exception Selenium will take a screenshot of the screen: pretty simple. The only caveat is that it won't work if Cruise is running as a service, and to get a decent result you'll probably need to maximize the web browser windows.

Suffering of Selenese Flu? Try webdriver

I've been suffering of selenese flu for months, being on a .net project we were using selenium RC. The typical symptoms are flaky, slow tests and sometimes a lot of sleeps in your code to make it work. Selenium has its age and it struggles to cope with the current web 2.0 asynchronous calls & rich javascript. Fortunately old good Simon is working hard at Google on webdriver, and in December the official port has been released also for the .net platform. It works alright, there are some classes missing and you have to put the IE dll on your project as a content so that it gets copied on the bin folder to make it work. A part from that, it's faster, more reliable, more fun to write. It's time to cure your flu, webdriver is your medication.