TestComplete samples (both built-in and additional) are located in the <Users>\Public\Public Documents\TestComplete 14 Samples folder.
Some file managers display the Public Documents folder as Documents.
TestComplete provides full support for automated testing of applications based on the Microsoft Silverlight technology. The following topic provides a brief overview of testing Silverlight applications with TestComplete.
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. With TestComplete you can test applications created with Silverlight 4 - 5 and running within the following web browsers:
Microsoft Internet Explorer ver. 10 - 11, including Silverlight 5 applications running in 64-bit versions of Internet Explorer.
Any web browser based on the Microsoft WebBrowser control.
Microsoft has added the ability to deploy a Silverlight application on a local computer. Such applications are called Out-of-Browser Silverlight Applications. TestComplete can test Out-of-Browser Silverlight Applications, however it uses another testing approach and obtains less access to the application internals. You can also use the same approach to test Silverlight applications running in Firefox.
To test Silverlight applications, TestComplete needs to get scripting access to the applications’ internals. Currently, you can get access to Silverlight applications and make them testable in two ways.
When a Silverlight application is running in one of the supported browsers, TestComplete automatically exposes its internal objects, methods and properties. In more complex cases, (for instance when HTTPS or cross-domain communication is used), you need to prepare your Silverlight application for testing. For more information on this, see Preparing In-Browser Silverlight Applications for Testing.
Once a Silverlight application is treated as an Open Application, TestComplete can identify all the objects in the application, record and play back user interactions with them.
To test Silverlight applications running in Firefox and out-of-browser Silverlight applications, use the functionality provided by the UI Automation engine. However, in this case, TestComplete only partially exposes the controls of Silverlight applications and does not provide scripting access to the applications’ native objects and their members.
|Further information of this section relates to testing of in-browser Silverlight applications. To learn about testing of out-of-browser Silverlight applications, see the Using Microsoft UI Automation Technology section.|
In order to test a Silverlight application, you need to properly configure your testing environment. This may include preparing the application to be tested, changing some web browser settings, and so on. For a complete checklist, see the following topics:
With TestComplete, you can record and play back user actions in Silverlight applications, or you can create tests manually from scratch. Usually, it is easier to record the test first and then modify and enhance the recorded test.
When you record a test, you interact with the tested Silverlight application as an end-user would: navigate through the application’s screens, fill out forms and so on. TestComplete captures all actions you perform in the application and adds them to the test.
A test consists of a sequence of operations that define various interactions with objects in the tested application. For example, in the sample test below you can see that item selection from a combo box is represented by the
ClickItem operation, clicking a button - by the
ClickButton operation, and so on.
browser = Aliases.browser;
vobject = browser.pageOrders.Form.Silverlightcontrolhost.object;
editOrder = vobject.Popup.EditOrder;
textBox = editOrder.cname;
def Test1(): browser = Aliases.browser; browser.ToUrl("http://secure.smartbearsoftware.com/samples/testcomplete14/silverlight/orders.html"); vobject = browser.pageOrders.Form.panelSilverlightcontrolhost.object; vobject.NewButton.ClickButton; editOrder = vobject.Popup.EditOrder; editOrder.ProductComboBox.ClickItem("FamilyAlbum"); textBox = editOrder.cname; textBox.Click(17, 11); textBox.SetText("Bender Rodriguez"); editOrder.OKButton.ClickButton;
Set browser = Aliases.browser
Set vobject = browser.pageOrders.Form.Silverlightcontrolhost.object
Set editOrder = vobject.Popup.EditOrder
Set textBox = editOrder.cname
Call textBox.Click(17, 11)
Call textBox.SetText("Bender Rodriguez")
var browser : OleVariant;
var vobject : OleVariant;
var editOrder : OleVariant;
var textBox : OleVariant;
browser := Aliases.browser;
vobject := browser.pageOrders.Form.panelSilverlightcontrolhost.object;
editOrder := vobject.Popup.EditOrder;
textBox := editOrder.cname;
browser = Aliases["browser"];
vobject = browser["pageOrders"]["Form"]["panelSilverlightcontrolhost"]["object"];
editOrder = vobject["Popup"]["EditOrder"];
textBox = editOrder["cname"];
The recorded tests can be modified and enhanced in a number of ways to create more flexible and efficient tests. For example, you can:
Add new operations, reorder operations and modify their parameters.
Delete or disable unneeded operations (for example, superfluous recorded operations).
Insert checkpoints for verifying objects and values in the tested application.
Create data-driven tests that run multiple test iterations using different sets of data.
Refer to the following topics to learn more about creating and enhancing tests:
|Creating tests using recording||Recording Tests|
|Creating tests manually||Keyword Testing and Scripting|
|Simulating user actions||Working With Application Objects and Controls|
|Running tests||Running Tests|
|Launching applications automatically at the beginning of the test run||Launching Browsers and
About Tested Applications
|Creating checkpoints for verifying application behavior and state||Checkpoints|
|Running multiple test iterations using data from an external file||Data-Driven Testing|
There are two major test formats in TestComplete:
Keyword tests - visually configured tests with grid-based editing interface. Best suited for novice users and those without programming knowledge.
Scripts - code written in one of the supported scripting languages. May be better suited for advanced users.
You select the test type when creating a test and cannot change it later. However, you can mix keyword tests and scripts within the same test project and call them from each other.
TestComplete also includes additional test types, such as low-level procedures, unit tests, distributed tests and so on. You can use them to address specific testing needs. However, most automation is typically done using keyword tests and scripts.
Each object in an application has a number of properties, such as its location, text, type and so on. Some object properties are persistent and unchanging, and therefore can be used to locate objects in applications and differentiate among various objects.
When you record a test, TestComplete captures all windows and controls that you interacted with during the recording session and adds them to the Name Mapping project item (also known as the object repository or GUI map). For each captured object, TestComplete does the following:
Selects a set of properties and values that uniquely identify the object in the application and saves them to Name Mapping as the object identification criteria. These properties will be used for locating the object during subsequent test recording, editing and run sessions.
Generates an alias (name) that will be used to reference this object in tests. By default, TestComplete generates aliases based on object names defined in the application by developers.
Automatically captures and adds images of the mapped objects to the Name Mapping repository. This helps you understand which window or control one or another mapped object matches.
The following image shows sample Name Mapping for a Silverlight application:
Here, the NewButton object is identified only by one property -
SlObjectName. This property specifies the object name as it is defined by the application developers in the application’s source code.
However, Silverlight application objects can also be located by other properties, such as their class name, text and so on -- whatever best identifies a specific object.
If needed, you can modify the default Name Mapping generated by TestComplete. For example, you can:
Change the identification properties and values to define more robust identification criteria or to reflect major GUI changes in newer versions of the tested application.
Rename aliases to more meaningful and descriptive aliases, so that it is easier for you to understand which object is which.
Manually add new objects to Name Mapping.
For more information, see Name Mapping.
Keep in mind that the object hierarchy in Name Mapping mirrors the object hierarchy in the tested application. When locating an object, TestComplete takes into account its entire parent hierarchy. If any object in the parent hierarchy cannot be found using the specified property values, the target object cannot be located as well. That is why it is important to select unique and unchanging properties for object identification.
TestComplete includes a number of special features for testing frequently used standard and third-party Silverlight controls. For detailed information on this, see Support for Silverlight Applications' Controls.
TestComplete exposes visual objects of an in-browser Silverlight application, as well as its internal objects, and provides scripting access to their public properties, fields and methods. See Accessing Native Properties and Methods of Silverlight Objects.
Besides, TestComplete can access namespaces and their classes defined in the application’s assemblies and call the constructors and static members of these classes. For detailed information on how to address exposed objects and their properties and methods from your tests, see Addressing Objects of In-Browser Silverlight Applications
TestComplete treats visual objects of a Silverlight Application 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.
Also, TestComplete extends each exposed object with a number of helper read-only properties (for instance,
SlFullClassName, etc.) that are listed in the Silverlight category on the Properties tabbed page of the Object Browser. Using these helper properties, you can obtain the class name of a Silverlight object (for instance,
RadioButton), the full class name (that is, the class name with its namespace, for instance,
System.Windows.Controls.RadioButton) and some other information about the object.
To see what operations (methods) are available for objects in your tested Silverlight application, as well as the object properties and their values, you can use the Object Browser or Object Spy. The available properties and methods include those provided by TestComplete, as well as native object properties and methods defined by the developers in the application’s source code.
You can view the object properties and methods both at design time and at run time when the test is paused.
TestComplete includes a sample project with Silverlight application tests:
|Note:||If you do not have the sample, download the TestComplete Samples installation package from the https://support.smartbear.com/downloads/testcomplete/samples/ page of our website and run it.|
These tests work with the Orders sample application on our web site:
For more information about automating tests with TestComplete, refer to the following sections: