Applies to TestComplete 14.10, last modified on June 5, 2019

About Object Mapping

Depending on the development tool, various applications use various classes to implement the same control. For instance, Microsoft Visual C++ implements tree view controls via the CTreeView class while Borland Delphi and C++Builder use the TTreeView class.

During test recording, TestComplete detects the class name of controls and uses it to find a suitable test object. Then it uses the properties and methods of the test object to represent user actions performed on the control. Linking a control’s class name to a test object is called object mapping.

Let’s see how it works. Suppose, in our test we interact with Windows Explorer. It uses a tree view control to show a tree of folders. Without object mapping, TestComplete will record only mouse clicks within the Explorer window:

JavaScript, JScript

p = Sys.Process("explorer");
w = p.Window("ExploreWClass", "My Computer");
// TestComplete notes the mouse click
w.Window("SysTreeView32").Click(49, 23);

Python

p = Sys.Process("explorer")
w = p.Window("ExploreWClass", "My Computer")
# TestComplete notes the mouse click
w.Window("SysTreeView32").Click(49, 23)

VBScript

Set p = Sys.Process("explorer")
Set w = p.Window("ExploreWClass", "My Computer")
' TestComplete notes the mouse click
Call w.Window("SysTreeView32").Click(49, 23)

DelphiScript

p := Sys.Process('explorer');
w := p.Window('ExploreWClass', 'My Computer');
// TestComplete notes the mouse click
w.Window('SysTreeView32').Click(49, 23);

C++Script, C#Script

p = Sys["Process"]("explorer");
w = p["Window"]("ExploreWClass", "My Computer");
// TestComplete notes the mouse click
w["Window"]("SysTreeView32")["Click"](49, 23);

If we map the tree view control’s class (SysTreeView32) to the Win32TreeView object, TestComplete will record user actions on the tree view as calls to the Win32TreeView object’s methods:

JavaScript, JScript

p = Sys.Process("explorer");
w = p.Window("ExploreWClass", "My Computer");
// TestComplete notes the high-level call
w.Window("SysTreeView32").ClickItem("|Desktop|My Computer");

Python

p = Sys.Process("explorer")
w = p.Window("ExploreWClass", "My Computer")
# TestComplete notes the high-level call
w.Window("SysTreeView32").ClickItem("|Desktop|My Computer")

VBScript

Set p = Sys.Process("explorer")
Set w = p.Window("ExploreWClass", "MyComputer")
' TestComplete notes the high-level call
Call w.Window("SysTreeView32").ClickItem("|Desktop|My Computer")

DelphiScript

p := Sys.Process('explorer');
w := p.Window('ExploreWClass', 'My Computer');
// TestComplete notes the high-level call
w.Window('SysTreeView32').ClickItem('|Desktop|My Computer');

C++Script, C#Script

p = Sys["Process"]("explorer");
w = p["Window"]("ExploreWClass", "My Computer");
// TestComplete notes the high-level call
w["Window"]("SysTreeView32")["ClickItem"]("|Desktop|My Computer");

This way, using object mapping makes your tests more robust and readable.

Object Mapping Settings

Each project in TestComplete has Object Mapping settings that specify controls TestComplete can recognize. For each control type, it provides a list of classes associated with this type. For instance, the Win32 TreeView type is associated with *TreeView* classes; that is, all Win32 controls whose class name includes the TreeView string are associated with the TreeView object.

All types of controls supported by TestComplete are organized into the following categories:

Android Controls

Borland Controls

Developer Express Controls

Flex Controls

Infragistics Controls

iOS Controls

JavaFX Controls

Microsoft Controls

Oracle Forms Controls

Qt Controls

Rogue Wave Controls

Swing Controls

Syncfusion Controls

Telerik Controls

TMS Software

Win32 Controls and Windows

WPF Controls

Xamarin.Forms Controls

Xceed Controls

Besides the mentioned categories and control types, the Object Mapping settings can include categories and items provided by custom control support plugins.

Each type is supposed to hold class names of the corresponding standard control and/or its descendants. Mapping a control to an improper type (for instance, mapping a tree view control to a Toolbar type) will cause errors during recording and simulating actions over controls in general.

To learn whether TestComplete recognizes your custom control as a supported control, analyze your custom control’s class name. If the custom control’s class name matches any of the supported classes, TestComplete will recognize your control as the appropriate control type and will provide extended properties and methods to simulate user actions on it. To learn the class name of your custom control, locate your control in the Object Browser and check one of the following properties (depending on your control type): WndClass, ClassName, ClrFullClassName, JavaFullClassName or QtClassName. You can also learn the control’s class name from the tested application’s developers.

You associate a control’s class name with a supported type or remove an association on the Properties > Object Mapping page of your project. You can also modify mapping associations in the Object Mapping section of the Default Project Properties dialog. In this case, TestComplete will apply the specified mapping settings to each new project you create.

To map a control class name
  1. Select the type to which you want to map the control.

  2. Click Add Class Name and enter the control’s class name.

– or –

  1. Make sure that the application containing your custom control is running and the control is visible on screen.

  2. On the Properties > Object Mapping page of your project, select the type to which you want to map the control.

  3. Click Add From Screen. This will call the Add New Object Class dialog.

  4. Select the desired control and click OK. TestComplete will add the control’s class name to the list.

  5. If an item is selected in the class names list before you call the dialog, TestComplete will ask whether you want to replace the selected item or add a new item to the list. To replace the selected class name, click Yes. Click No to leave the selected item unchanged and add the captured class name to the list.

Class names are case-insensitive. In addition, you can use the asterisk (*) and question mark (?) wildcards in class names. The asterisk corresponds to the string of any length, the question mark—to any single character. Use wildcards to create class name templates that associate a group of similar class names with a specific type. For example, the *TreeView* template matches all class names that include the TreeView substring.

TestComplete interacts with controls of a specific type via the interface that is supported by standard controls of this type. So, if a custom control does not support the required interface or implements it improperly (which can take place if it is neither a standard control nor its descendant), Object Mapping will not be helpful. That is, TestComplete will extend the control with supplementary properties and methods, but they will not work.
To modify an associated class name
  1. Click the desired class name in the list.

  2. Enter a new class name in the in-place editor. Press Enter to confirm the changes or Esc to cancel them.

To map the descendants of the associated class

To associate a control type with a class and its descendant classes, select the Derived Classes check box next to the control’s class name.

To disable a class name association

Clear the Enabled check box.

To remove a class name association
  1. Select the desired class name in the list.

  2. Click Remove Class Name or Del.

However, we recommend that you disable class name associations rather than remove them. Removing a predefined association will affect the way TestComplete works with standard controls.

Remarks

  • TestComplete recognizes and shows the control lists only if you have an active license for the appropriate TestComplete module, and support for the controls is enabled in the File > Install Extensions dialog. For example, in order for TestComplete to recognize Borland TDBGrid controls, you must have a license for the Desktop module and VCL Control Support must be enabled in TestComplete. An exception to this is Win32 controls—any TestComplete module supports them by default.
  • Sometimes, TestComplete may recognize an ordinary (non-control) window as one of the supported controls. This happens if the window’s class name matches a class name associated with the control. The issue can be solved by disabling the corresponding mapping association in the project’s Object Mapping options.

See Also

Object Identification
Project Properties - Object Mapping Options
Supported Controls

Highlight search results