Thanks to Justin and Jason for pointing out WatiN. WatiN is inspired by Watir but build for the .NET framework. This means you can write your unit tests using C#, VB or any CLS complaint language. I used WatiN with MbUnit and it worked super great! Let's check out some of the code below:
You need to add reference to MbUnit.Framework and WatiN.Core.
[TestFixture(ApartmentState=ApartmentState.STA)]
public class TestLoginPage
{
[Test]
public void TestCanAuthenticatedUserLoginSuccessfully()
{
IE ie = new IE("http://localhost:2334/Login.aspx");
string finalUrl = "http://localhost:2334/HomePage.aspx";
ie.TextField(Find.ById("txtUserName")).TypeText("AzamSharp");
ie.TextField(Find.ById("txtPassword")).TypeText("mypassword");
ie.Button("Button1").Click();
Assert.AreEqual(finalUrl, ie.Url);
// close the window
ie.Close();
}
}
Pretty awesome! The code will open a new window fill out all the fields and press the Submit button.
Thanks Jason and Justin! :)