Calling Methods and Properties of "Internal" Objects

Applies to TestComplete 15.69, last modified on November 13, 2024

Keyword test operations that simulate user actions only work with windows and controls. However, sometimes you may need to work with an object that exists within the window or control, but it is not treated by TestComplete as a child object. In other words, these objects are not shown in the Object tree of the Object Browser panel and you cannot choose them, for example, when adding operations to your keyword test. Examples of such objects are vertical and horizontal scroll bars. Access to these objects is provided via properties of the objects’ parent window or control. For instance, to scroll you use the VScroll and HScroll properties of the window object.

To simulate user actions over an “internal” object, you should obtain this object and then “call” the method that will perform the desired action. There are several ways in which you can do this. Below are two possible solutions that use the On-Screen Action and Run Code Snippet operations.

Using the On-Screen Action Operation

The On-Screen Action operation is used to simulate user actions over windows and controls. Here is how you can use it to simulate user actions over “internal” objects:

  • Open your keyword test in the Keyword Test editor.

  • Add the On-Screen Action operation from the Operations list to your test. TestComplete will display the Operation Properties dialog.

  • In the dialog, specify the parent window or control of the target object and click Finish. TestComplete will append the operation to the test.

  • Right-click the operation in the test and select Work With Object Through Property from the context menu. TestComplete will display the Select Property dialog listing all properties of the selected window or control that return object references.

  • In the dialog, choose the property that returns the desired object (for example, VScroll or HScroll) and click OK. TestComplete will replace the operation’s name in the Item column of the Keyword Test editor with the name of the selected property.

  • Select the action to be performed from the drop-down list in the Operation column of the Keyword Test editor and specify the action parameters in the Value column.

Using Script Code

An alternative approach to call methods of an “internal” object from a keyword test is to use the Run Code Snippet operation:

  • Open your keyword test in the Keyword Test editor.

  • Add the Run Code Snippet operation to your test. TestComplete will display the Operation Parameters dialog.

  • Type the name of the object’s parent window or control in the edit box, or click Pick Object and select that window (control) from the screen.

  • Append the name of the property providing access to the desired “internal” object along with the name of the object’s method or property to be called by the code in the edit box. For example:

    JavaScript, JScript

    Sys.Process("MyApp").Window("WndClass", "*", -1).VScroll.Pos = 10;

    Python

    Sys.Process("MyApp").Window("WndClass", "*", -1).VScroll.Pos = 10

    VBScript

    Sys.Process("MyApp").Window("WndClass", "*", -1).VScroll.Pos = 10

    DelphiScript

    Sys.Process('MyApp').Window('WndClass', '*', -1).VScroll.Pos := 10;

    C++Script, C#Script

    Sys["Process"]("MyApp")["Window"]("WndClass", "*", -1)["VScroll"]["Pos"] = 10;

See Also

Keyword Tests
Keyword Tests
Test Actions Category
Common Tasks for Keyword Test Operations

Highlight search results