This topic contains general information about testing out-of-browser Silverlight applications via the Microsoft UI Automation technology:
Silverlight applications are Rich Internet Applications (RIA) which are executed in web browsers. In-browser mode is the essential and most common way to use them, however Silverlight applications can also be launched in out-of-browser mode. In this mode the application is wrapped in a special utility (sllauncher.exe) and behaves like an ordinary desktop application.
When a Silverlight application is running in the browser, TestComplete treats it as Open Application and provides scripting access to native objects properties, fields and methods.
Unfortunately, out-of-browser Silverlight applications cannot be tested in this way. To test out-of-browser Silverlight applications, you can use the UI Automation technology. Using the UI Automation engine, TestComplete can simulate user actions over application controls, such as mouse clicks, keyboard input, and so on (see Simulating User Actions). However, this technology only partially exposes controls of Silverlight applications and does not provide full access to them.
|TestComplete does not support Silverlight applications that are loaded by wrapper web pages directly from XAML files (.xaml) containing the applications’ source code. Due to some specifics of such applications, TestComplete cannot recognize the applications’ internal objects and does not provide access to them for testing. Thus, in order for a Silverlight application to be tested with TestComplete, the application must be compiled and packed to a .xap file from which a wrapper web page will load the application to run it.|
In order to test a Silverlight application via UI Automation, you need to properly configure your testing environment. For detailed information about the required actions, read the Preparing Test Projects for Testing Out-of-Browser Silverlight Applications topic.
You can create an automated test for a Silverlight application by recording interactions with the application and then modify the test if necessary, or you can create a test from scratch. For more information about creating and editing tests, see the following sections:
For easier control over your tested Silverlight application, you can add it to the Tested Applications collection of your test project (to learn how to do this, see Preparing Test Projects for Testing Out-of-Browser Silverlight Applications). This will allow you to quickly launch the application from the TestComplete IDE and from your tests. You can also command TestComplete to automatically open your Silverlight application when you start recording a test. For more information, see Running Tested Applications.
You can extend your tests by adding various checkpoints for verifying the application’s objects and state, parameterizing values and reading test data from external files. For more information, see:
When a test is running, TestComplete performs test operations and logs the result of each operation. You can run a single test, as well as a series of tests one after another. Tests can be run from the TestComplete IDE or from the command line. See Running Tests.
For complete information about the testing process, see Working With TestComplete.
When testing your out-of-browser Silverlight application using the UI Automation engine, you can recognize visual objects and the objects obtained from UI Automation providers.
TestComplete treats visual objects of a Silverlight application exposed via UI Automation as
onscreen objects. So, the objects contain properties and methods common for
onscreen objects, such as
Drag and others. These methods can be used to simulate various user actions over the corresponding Silverlight objects.
onscreen object members, each object contains properties and methods exposed by the appropriate UI Automation provider. These properties and methods are included in the UI Automation category of the properties and methods displayed in the Object Browser. The set of extended properties and methods is specific for each control type. For example, DataGrid controls have the
ColumnCount properties and the
GetItem method for iterating through grid cells; tree items have the
Collapse methods and so on. For more information on the extended methods and properties, refer to the description of the appropriate provider in MSDN (the on-line version is available at http://msdn.microsoft.com). You can find a full list of predefined providers in the description of the
System.Windows.Automation.Provider namespace of .NET Framework.
Also, TestComplete extends each exposed Silverlight object with a couple of helper read-only properties,
ObjectGroupIndex, that are also listed in the UI Automation category on the Properties tabbed page of the Object Browser. Using these helper properties you can obtain the identifier of a Silverlight object and its index in the collection of sibling objects with the same identifier (if any). The values returned by these properties are used to address Silverlight objects via the
UIAObject method (see Addressing Objects of Out-of-Browser Silverlight Applications).