What's new in LTAF June release?
The June 2009 release of the Lightweight Test Automation Framework is out on CodePlex. Here is a small write up of the new features available.
Automation of frames
Now tests can automate pages that contain framesets and iFrames. For example:
[WebTestMethod]
public void Frame()
{
HtmlPage page = new HtmlPage("TestFrameSet.htm");
// get top frame
HtmlPage frame = page.GetFramePage("topFrame");
// verify title of frame
Assert.AreEqual("This is the top frame", frame.Elements.Find("h1", 0).GetInnerText());
}
Write to the test console
This is an experimental feature that is useful to debug tests. You can now write messages from your test into the test console that appears in the driver page. For example:
[WebTestMethod]
public void PopupPageWithIndex()
{
// Navigate to the frameset
HtmlPage page = new HtmlPage("TestFrameSet.htm");
//get the top frame
WebTestConsole.Write("Get the top frame");
HtmlPage frame = page.GetFramePage("topFrame");
// click on the button that opens a new page
WebTestConsole.Write("Click the openwindow button");
frame.Elements.Find("OpenWindow").Click();
...
When run, this test will output traces into the console UI:
Hide the test console
New option in the UI allows user to hide the test console. This is useful for long running test suites, to prevent the browser from maintain a grown list of commands.
Quickly verify page is rendering an asp.net error
New helper method in HtmlPage makes it easy to quickly verify if a asp.net error page is being rendered. This is useful to immediately stop the test if an error has occurred, instead of waiting for a timeout. For example:
[WebTestMethod]
public void VerifyTheAspNetErrorPage()
{
HtmlPage p = new HtmlPage("PageWithError.aspx");
bool pageFail = p.IsServerError();
Assert.IsFalse(pageFail);
...
}
Exposed test run lifecycle events
Users can now register handlers in the DriverPage.aspx to several life cycle events. This is useful, for example, to generate a custom log:
protected override void RunTestCases()
{
// if user checked the Write Log To Disk checkbox
if (this.WriteLogToDiskCheckBox.Checked)
{
// attach event handlers to write my custom log
this.TestcaseExecutor.TestcaseExecuted +=
new EventHandler<TestcaseExecutionEventArgs>(TestcaseExecutor_TestcaseExecuted);
this.TestcaseExecutor.TestRunFinished +=
new EventHandler<TestRunFinishedEventArgs>(TestcaseExecutor_TestRunFinished);
}
base.RunTestCases();
}
Additional Resources
Federico Silva Armas
SDET, ASP.NET QA Team