Applies to TestComplete 14.20, last modified on September 11, 2019

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

About Accessing Native Properties and Methods

TestComplete identifies individual GUI objects in Flash and Flex applications and provides specialized methods and properties for automating various operations with these objects, getting object data, checking the 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 Flash and Flex 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 Flash or Flex application, even those that are not accessible via the application’s GUI.

The Object Browser marks objects of Flash and Flex applications with the glyph. To view native properties and methods available for a Flash or Flex object, use the Object Spy or Object Browser in the Advanced view mode. TestComplete gives you access to public properties and methods via the FlexObject property (see Important Notes for details).

Native Properties of a Flex DataGrid Object in Object Browser

Click the image to enlarge it.

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

Getting Access to Flash and Flex Applications’ Native Properties and Methods

In order to get access to native properties and methods of a Flash or Flex application, you have to use the debug version of a Flash Player, the Runtime Loader utility or precompiled FlexClient library. Once you prepare your application and environment for testing, you can access the application’s public native methods and properties. For more information on testing approaches, see Approaches to Testing Flash and Flex Applications.

Note: When exposing a Flash or Flex application via MSAA, TestComplete does not provide you with access to the application’s public members.

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 Flash and Flex 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 a Flex form’s title using its native name property in the following way:

JavaScript, JScript

var title = Aliases.browser.AppPage.objectOrders.FlexObject.name;
Aliases.browser.AppPage.objectOrders.FlexObject.name = "New Window Title";

Python

title = Aliases.browser.AppPage.objectOrders.FlexObject.name;
Aliases.browser.AppPage.objectOrders.FlexObject.name = "New Window Title";

VBScript

Dim title
title = Aliases.browser.AppPage.objectOrders.FlexObject.name
Aliases.browser.AppPage.objectOrders.FlexObject.name = "New Window Title"

DelphiScript

procedure Test;
var title;
begin
  …
  title := Aliases.browser.AppPage.objectOrders.FlexObject.name;
  Aliases.browser.AppPage.objectOrders.FlexObject.name := 'New Window Title';
  …
end;

C++Script, C#Script

var title = Aliases["browser"]["AppPage"]["objectOrders"]["FlexObject"]["name"];
Aliases["browser"]["AppPage"]["objectOrders"]["FlexObject"]["name"] = "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 a Flex object’s native property value to a test variable

Click the image to enlarge it.

Setting a new value for a Flex 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

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 Flash and Flex 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 getFocus method of a Flex button as follows:

JavaScript, JScript

Aliases.browser.AppPage.objectOrders.editorderEditOrder.buttonBtnok.FlexObject.getFocus();

Python

Aliases.browser.AppPage.objectOrders.editorderEditOrder.buttonBtnok.FlexObject.getFocus();

VBScript

Aliases.browser.AppPage.objectOrders.editorderEditOrder.buttonBtnok.FlexObject.getFocus

DelphiScript

Aliases.browser.AppPage.objectOrders.editorderEditOrder.buttonBtnok.FlexObject.getFocus();

C++Script, C#Script

Aliases["browser"]["AppPage"]["objectOrders"]["editorderEditOrder"]["buttonBtnok"]["FlexObject"]["getFocus"]();

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

Invoking a Flex object’s native method

Click the image to enlarge it.

Important Notes

  • Native properties and methods of Flash and Flex objects can be accessed via the FlexObject property. For example, you can access the native Name property of a Flash or Flex application’s form as follows:

    JavaScript, JScript

    Aliases.Orders.MainForm.FlexObject.Name

    Python

    Aliases.Orders.MainForm.FlexObject.Name

    VBScript

    Aliases.Orders.MainForm.FlexObject.Name

    DelphiScript

    Aliases.Orders.MainForm.FlexObject.Name

    C++Script, C#Script

    Aliases["Orders"]["MainForm"]["FlexObject"]["Name"]

    Note that TestComplete gives you access to public properties and methods of the tested Flash or Flex application if you are testing your application by using the debug version of Flash Player, the Runtime Loader utility or the FlexClient library. The MSAA engine does not expose public members to your tests.

  • In the Object Spy and Object Browser, native properties and methods of Flash and Flex 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 Flash and Flex Applications

Highlight search results