Lightweight Test Automation Framework for ASP.NET Samples Release Notes

What is included in this release?

This release contains samples that show how the ASP.NET QA team creates automated tests by using the Lightweight Test Automation Framework for ASP.NET. The release is unsupported, and is provided in the form of samples only.

What is the Lightweight Test Automation Framework for ASP.NET?

The Lightweight Test Automation Framework for ASP.NET Samples was developed and is currently used by the ASP.NET QA Team to automate regression tests for the product. It is designed to run within an ASP.NET application.
Tests can be written in any .NET Framework language. They use an API to manipulate and verify the DOM of the browser. NexusLight supports running tests in Microsoft Internet Explorer, Mozilla Firefox, Apple Safari, and Opera.
Note that even though the Lightweight Test Automation Framework for ASP.NET can be used to automate testing for any general-purpose Web application, its design was driven by the needs of the QA Team to automate ASP.NET regression tests.

How do I use the samples?

1. Download the Lightweight Test Automation Framework Samples from the Web site and then open it in Visual Studio 2008. The Web site contains a small application and tests to automate it. The following illustration shows the Web site structure.

WebStructure.gif

2. Navigate to Home.aspx to interact with the Web site. To log in, use the user name ValidUser and use any string for the password. The page contains a GridView control that lets the user edit, delete, and insert data about school classes and grades. The following illustration shows a screen shot of the sample application.

SampleApp.gif

3. Navigate to \test\Default.aspx. This loads the testing UI, shown in the following illustration:

TestingUI.gif

4. Select tests from the tree view and then click Run Tests. The tests will run and display their progress in the right-hand frame.
5. To examine the test code, browse to the App_Code\Tests folder, and then open any file to inspect the test source code.

How do I debug test errors?

When a test fails, it is marked in red in the test tree. To examine the log, click the test name. The log information is displayed as shown in the following illustration:

Debug.gif

The log contains the stack trace of the test and the DOM that was captured by the Lightweight Test Automation Framework the moment of failure.
You can also have the test framework write a simple log to disk. To do so, select the Write Log to Disk check box before you run the tests. Note that this feature requires write access to the Web site’s root folder.

How do I use the Lightweight Test Automation Framework for ASP.NET with my own Web site?

1. Copy Microsoft.Web.Testing.Lightweight.dll into the Bin folder of your Web site. If you are testing a Web application, add the DLL as a reference to the project.

2. Copy Default.aspx and DriverPage.aspx into a folder in the Web site. By convention, the ASP.NET QA team uses the Test folder, but you can use any folder that you want. These are the pages that are required in order to run the tests.

3. If you are testing a Web site project, put tests in the App_Code folder. If you are testing a Web application project, you can put tests in any folder.

How do I use query-string arguments?

NexusLight accepts the following query-string arguments that are useful for filtering and running tests:
  • Tag=<tag_identifier>
    • Selects all tests that are marked with the WebTestTagAttribute and that have the specified identifier. For example, to have NexusLight automatically select a method that is marked with the [WebTestTag("DataScenarios")] attribute, you can navigate to the following URL:
http://server/site/test/Default.aspx?tag=DataScenarios
By default, the names of all classes that are marked with the WebTestClassAttribute and the name of all methods that are marked with the WebTestMethodAttribute are already identifiers.
  • You can specify multiple tag identifiers by concatenating them with the “@” symbol, as shown in the following example:
http://server/site/test/Default.aspx?tag=Pri0@MyTestMethod
This example shows how to automatically select all tests that have the [WebTestTag("Pri0")] attribute and additionally to select the test method named “MyTestMethod”.
  • Filter=[true|false]
    • Passing true causes the Lightweight Test Automation Framework to remove all unselected tests from the test tree.
  • Run=[true|false]
    • Passing true causes the Lightweight Test Automation Framework to start running the selected tests on load.

Additional Resources

For more information, see the following resources:
  • The ASP.NET QA Team blog, where you can find additional samples.
  • The ASP.NET QA Road Map document, which can be found within the ASP.NET CodePlex page. This document describes upcoming features.
  • The ASP.NET CodePlex page, where you can post questions and feedback.

Last edited Oct 17, 2008 at 5:28 PM by ScottGal, version 7

Comments

daveh551 Jun 11, 2010 at 3:08 PM 
What's the technique for verifying that a javascript alert has occurred and its properties (e.g., text)? The documentation is non-existent, and I haven't been able to find any samples that are doing it.

I have a button that will cause an alert (under certain conditions.) I click it using "continueButton.Click(new CommandParameter(WaitFor.None, PopupAction.AlertOK))". The alert box comes up, but the test stalls until I click on the OK manually, and I can't find anyway to verify that it has occurred, or to access it (such as to automagically click on the OK so the test can continue.)

I've also asked this in the LTAF asp.net forum, but that appears to be pretty low traffic.
Thanks for any help.

chan May 23, 2009 at 1:37 AM 
I've installed LTAF and play around a little bit with it and I think it would be very useful to have a recorder to avoid writing a lot of code ourselves.

Keep up the good work! :D

farmas Oct 5, 2008 at 3:29 AM 
Oleg, we do not have a UI test recorder, and we are not planning on creating one :-(

Keep in mind that this framework was driven by requirements of the QA Team to test ASP.NET, and for the most part we create "sample pages" that use the features to verify, we control the markup and they are usually very easy to write automation for. We seldom automate full blown applications, where a recorder might save a lot of time.

- Federico

OlegAxenow Sep 29, 2008 at 10:41 AM 
Federico, thanks for the explanation.

Do you have a public version of UI test recorder (for initial test generation)?
If no, are you planning to add test recorder into the future releases?

Best Regards, Oleg.

farmas Sep 27, 2008 at 2:57 PM 
panjkov, thanks for the feeback. I'll update the notes to make this clear.

Oleg, the support of multiple browsers is definetly a reason. The story of this framework goes back 3 years when the team was working on the Atlas project, we investigated other frameworks back then, and one of the reasons we chose to proceed with this was we could not make changes to other test frameworks to support some of the requirements that we had. Unfortunately, I am not familiar enough with WatiN to make a comparison.

- Federico

OlegAxenow Sep 25, 2008 at 7:25 AM 
Interesting tool!

You use it, only because WatiN does not support Opera and Safari, or any other advantages exist?

Best Regards, Oleg.

panjkov Sep 25, 2008 at 7:09 AM 
it is unclear about tests. one must CREATE tests in App_Code folder. Test class must be decorated with [WebTestClass] and must contain methods decorated with [WebTestMethod]. It also need to reference Microsoft.Web.Testing.Light;