How to Use the Windows nativeObject API

One of Squish's most useful features is the ability to access the toolkit's API from test scripts. This gives test engineers sufficient flexibility to allow them to test just about any aspect of the AUT.

With Squish's Windows Object API it is possible to find and query objects, call methods, and access properties. In addition, Squish provides a convenience API (Windows Convenience API) to execute 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

{}

© 2022 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.