// Will initialize a new AspNetApplication object.
Manager.LaunchNewBrowser();
// Request the page we want.
ActiveBrowser.NavigateTo(PAGE_NAME);
// We can access raw http request properties when the
// browser is AspNetHost.
if (ActiveBrowser.BrowserType == BrowserType.AspNetHost)
{
// we wrap this part with an if..else statement so that
// this test can still run on other browsers without
// having to perform any recompilation.
AspNetHostBrowser hostBrowser = (AspNetHostBrowser)ActiveBrowser;
// get the last status code for the last response.
// You can also access the full Request/Response objects using
// hostBrowser.AspNetAppInstance.LastResponse
// or
// hostBrowser.AspNetAppInstance.LastRequest
Assert.IsTrue(hostBrowser.Status == 200);
}
else
{
// Do some other type of verification...
}
Element label = ActiveBrowser.Find.ById("label1");
// Click a button
Actions.Click(Find.ById("button1"));
label.Refresh();
Assert.IsTrue(label.InnerText.Contains("Button1 Clicked"));
// Click a linkbutton
Actions.Click(Find.ById("linkbutton1"));
label.Refresh();
Assert.IsTrue(label.InnerText.Contains("LinkButton1 Clicked"));
// Set Text
Actions.SetText(Find.ById("textbox1"),"Hello!");
label.Refresh();
Assert.IsTrue(label.InnerText.Contains("Hello!"));
//Select From DropDown
Actions.SelectDropDown(Find.ById("dropdownlist1"), "Item2");
label.Refresh();
Assert.IsTrue(label.InnerText.Contains("Item2"));
// Select a link on the calendar.
string dateToSelect = DateTimeFormatInfo.CurrentInfo.GetMonthName(DateTime.Today.Month) + " " +
string.Format("{0:00}", DateTime.Today.Day);
Actions.Click(Find.ByAttributes("title=~" + dateToSelect));
label.Refresh();
Assert.IsTrue(label.InnerText.Contains(DateTime.Today.ToShortDateString()));
// Select a node in a treeview
Actions.Click(Find.ById("treeView1t1"));
label.Refresh();
Assert.IsTrue(label.InnerText.Contains("Node2"));