Testing Drupal with Watin : Watching For Errors
Submitted by aaron on Fri, 07/03/2009 - 15:49
The following class can be used to override the standard IE object in WatiN to run specific tests after every page load. For example, in Drupal this class can be used to make sure that no error messages appear on any page during the test run.
private class IEDrupal : IE
{
public IEDrupal(String url)
: base(url)
{
}
private void VerifyNoErrorMessagesPresent()
{
Div div_error = this.Div(Find.ByClass("messages error"));
Assert.IsFalse(div_error.Exists);
}
public String lastUrl = "";
public override void WaitForComplete(int waitForCompleteTimeOut)
{
base.WaitForComplete(waitForCompleteTimeOut);
//only do this check if the url has changed - otherwise it really slows down typing
if (this.Url != lastUrl)
{
VerifyNoErrorMessagesPresent();
lastUrl = this.Url;
}
}
}


