How to Test Windows Applications

Squish's Windows Object API enables you to find and query objects, call methods, and access properties.

In addition, the Windows Convenience API contains functions for executing common GUI actions, such as clicking a button or typing text into a control. Windows objects are made available in a wrapper, and the underlying objects' properties and methods are accessible through the Squish-added nativeObject property.

For example, to access the items in a windowsforms list view, we would first obtain a reference to the list view, and then access the items:

listview = waitForObject(":_ListView")
items = listview.nativeObject.Items
item1 = items.at(0)
var listview = waitForObject(":_ListView");
var items = listview.nativeObject.Items;
var item1 = items.at(0);
my $listview = waitForObject(":_ListView");
my $items = $listview->nativeObject->Items;
my $item1 = $items->at(0);
listview = waitForObject(":_ListView")
items = listview.nativeObject.Items
item1 = items.at(0)
set listview [waitForObject ":_ListView"]
set items [property get [property get $listview nativeObject] Items]
set item1 [invoke $items at 0]

Here is another example that writes the names of a windows object's methods (in this case a list view) to the Squish log.

listViewType = listview.nativeObject.GetType()
methods = listViewType.GetMethods()
for method in methods:
    test.log("ListView method: " + method.Name)
var listViewType = listview.nativeObject.GetType();
var methods = listViewType.GetMethods();
for (i = 0; i < methods.length; ++i)
    test.log("ListView method: " + methods.at(i).Name);
my $listViewType = $listview->nativeObject->GetType();
my @methods = $listViewType->GetMethods();
foreach $method (@methods) {
    test.log("ListView method: " . $method->Name);
}
listViewType = listview.nativeObject.GetType()
methods = listViewType.GetMethods()
for method in methods
    Test.log("ListView method: " + method.Name)
end
set listViewType [invoke [property get $listview nativeObject] GetType]
set methods [invoke $listViewType GetMethods]
foreach method $methods {
    set name [property get $method Name]
    test.log("ListView method: $name")
}

[Under Construction ]