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 ]

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results