Accessing Native Properties and Methods of AIR Objects

Applies to TestComplete 14.72, last modified on April 22, 2021

The information in this topic applies to web tests that locate web objects by using internal identification properties provided by TestComplete and run in local environments.

TestComplete provides you with access to individual objects of AIR applications, their internal properties and methods. The following sections describe how you can access these native properties and methods from your tests:

About Accessing Native Properties and Methods

TestComplete identifies individual GUI objects in AIR applications and provides specialized methods and properties for automating various operations on these objects, getting object data, checking state and so on. However, if these predefined properties and methods are insufficient for your testing needs, you can use native properties and methods of AIR objects to complete desired tasks. These are the same properties and methods that are available for use in the tested application’s source code as well as custom properties and methods implemented by the application developers. This way, you can perform almost any operations in the tested AIR application, even those that are not accessible via the application’s GUI.

The Object Browser marks objects of AIR applications with the glyph. To view native properties and methods available for an AIR object, use the Object Spy or Object Browser in the Advanced view mode. Note that TestComplete gives you access to the following members in your AIR applications (see Important Notes for details):

  • Public native properties and methods in Flex-based AIR applications.
  • Public native properties in HTML-based AIR applications.
Native Properties of an AIR DataGrid Object in Object Browser

Click the image to enlarge it.

For more information on how to refer to objects in AIR applications, see Addressing Objects in AIR Applications.

Getting and Setting Native Object Properties

To access an object’s property in script code, you specify the property name after the object name using the dot operator "." (in VBScript, JScript, Python and DelphiScript projects) or the square bracket notation [" "] (in C++Script and C#Script projects).

Note: Note that native properties and methods of AIR objects are displayed under the FlexObject property in the Flex category. For detailed instructions on how to get access to internal members in your keyword tests, see Calling Methods and Properties of "Internal" Objects.

For example, you can get and set an AIR form’s title using its native title property in the following way:

JavaScript, JScript

var title = Aliases.Orders.wndOrders.FlexObject.title;
Aliases.Orders.wndOrders.FlexObject.title = "New Window Title";

Python

title = Aliases.Orders.wndOrders.FlexObject.title;
Aliases.Orders.wndOrders.FlexObject.title = "New Window Title";

VBScript

Dim title
title = Aliases.Orders.wndOrders.FlexObject.title
Aliases.Orders.wndOrders.FlexObject.title = "New Window Title"

DelphiScript

procedure Test;
var title;
begin
  …
  title := Aliases.Orders.wndOrders.FlexObject.title;
  Aliases.Orders.wndOrders.FlexObject.title := 'New Window Title';
  …
end;

C++Script, C#Script

var title = Aliases["Orders"]["wndOrders"]["FlexObject"]["title"];
Aliases["Orders"]["wndOrders"]["FlexObject"]["title"] = "New Window Title";

In keyword tests, you can retrieve an object’s property value and save it to a test variable using the Set Variable Value operation. To change a property value, you can use the On-Screen Action operation to call the property’s [Set] method. For more information, see Getting and Setting Object Property Values.

Saving an AIR object’s native property value to a test variable

Click the image to enlarge it.

Setting a new value for an AIR object’s native property

Click the image to enlarge it.

You can also create checkpoints to verify values of native object properties.

Calling Native Object Methods

When testing a Flex-based AIR application, you can call its object’s methods from your tests.

Native methods of HTML-based AIR applications are not accessible from your tests.

To call an object’s method from script code, you use the dot operator "." (in VBScript, JScript, Python and DelphiScript projects) or the square bracket notation [" "] (in C++Script and C#Script projects) to specify the method name after the object name.

Note: Note that native properties and methods of AIR objects are displayed under the FlexObject property in the Flex category. For detailed instructions on how to get access to internal members in your keyword tests, see Calling Methods and Properties of "Internal" Objects.

For example, in script code you can call the native setFocus method of an AIR button as follows:

JavaScript, JScript

Aliases.Orders.wndOrders.ordersOrders0.buttonbarButtonbar11.buttonNewOrder.FlexObject.setFocus();

Python

Aliases.Orders.wndOrders.ordersOrders0.buttonbarButtonbar11.buttonNewOrder.FlexObject.setFocus();

VBScript

Aliases.Orders.wndOrders.ordersOrders0.buttonbarButtonbar11.buttonNewOrder.FlexObject.setFocus

DelphiScript

Aliases.Orders.wndOrders.ordersOrders0.buttonbarButtonbar11.buttonNewOrder.FlexObject.setFocus();

C++Script, C#Script

Aliases["Orders"]["wndOrders"]["ordersOrders0"]["buttonbarButtonbar11"]["buttonNewOrder"]["FlexObject"]["setFocus"]();

In keyword tests, you can use the On-Screen Action operation to call an object’s native method. For more information, see Calling Object Methods.

Invoking an AIR object’s native method

Click the image to enlarge it.

Important Notes

  • Native properties and methods of AIR objects can be accessed via the FlexObject property. For example, you can access the native title property of an AIR application’s form as follows:

    JavaScript, JScript

    Aliases.Orders.wndOrders.FlexObject.title

    Python

    Aliases.Orders.wndOrders.FlexObject.title

    VBScript

    Aliases.Orders.wndOrders.FlexObject.title

    DelphiScript

    Aliases.Orders.wndOrders.FlexObject.title

    C++Script, C#Script

    Aliases["Orders"]["wndOrders"]["FlexObject"]["title"]

    For detailed instructions on how to get access to internal members in your keyword tests, see Calling Methods and Properties of "Internal" Objects

    Note that TestComplete gives you access to public native properties and methods of Flex-based AIR applications. If your tested AIR application is HTML-based, you can access its native public properties. Native public methods of HTML-based AIR applications are not exposed by TestComplete.

  • In the Object Spy and Object Browser, native properties and methods of AIR objects are displayed only in the Advanced view mode.

  • The leading underscore ( _ ) in property and method names is replaced with the character z. For example, a property named _flag is accessible as zflag, a method named __reset() is accessible as z_reset(), and so on.

See Also

Testing AIR Applications

Highlight search results