To do automated web tests of your projects you can use a cool tool called Watin.
“Welcome at the WatiN (pronounced as What-in) website. Inspired by Watir development of WatiN started in December 2005 to make a similar kind of Web Application Testing possible for the .Net languages. Since then WatiN has grown into an easy to use, feature rich and stable framework. WatiN is developed in C# and aims to bring you an easy way to automate your tests with Internet Explorer and FireFox using .Net.”
Once you have Watin you can then write tests like this that will open up your browsers go to the page you are working on, add values, click buttons etc and help to make sure your projects work as you expect.
/// <summary>
/// Searches for WatiN on google using both Internet Explorer and Firefox.
/// </summary>
[Test]
public void SearchForWatiNOnGoogleUsingBaseTest()
{
// Call ExecuteTest in the base class, the base class handles creating and disposing
// of browser instances, and will call the passed in delegate
// SearchForWatiNOnGoogleUsingBaseTest(IBrowser browser) once for each type of
// browser supported by WatiN (Internet Explorer and Firefox at the moment).
base.ExecuteTest(SearchForWatiNOnGoogleUsingBaseTest);
}
/// <summary>
/// Searches for WatiN on google using the passed in <paramref name="browser"/>.
/// </summary>
/// <param name="browser">The browser.</param>
private void SearchForWatiNOnGoogleUsingBaseTest(IBrowser browser)
{
GoTo("http://www.google.com", browser);
browser.TextField(Find.ByName("q")).Value = "WatiN";
browser.Button(Find.ByName("btnG")).Click();
Assert.IsTrue(browser.ContainsText("WatiN"));
}
The base.ExecuteTest method actually runs the test in both IE and Firefox. Cool eh. To get the tests to work in FF3 you’ll need the jssh.xpi Extension which you can get from here http://wiki.openqa.org/display/WTR/FireWatir+Installation.
Now you will be able to run the example tests that come with Watin. Enjoy and watch your hard work automatically execute itself in front of you.
Tip: make sure you don’t have any instances of FF3 running when you run your tests.