Accessing a FoxPro Application's Internal Objects

  May 31, 2006

You probably already know that you can test FoxPro applications by simulating mouse clicks, keystrokes, using low-level procedures, manual tests and various other features provided by TestComplete. But, did you know that if your application was compiled with Microsoft Visual FoxPro 7.0 or later, you can gain access to your application’s internal objects, methods and properties using TestComplete's MSAA engine?

Since FoxPro application windows and controls support Microsoft Active Accessibility, they are exposed through the IAccessible interface. You can access these methods and properties through the Object Browser panel's Properties and Methods pages. To address exposed objects, TestComplete uses the window object's MSAAObject and WaitMSAAObject methods.

MSAA Open Applications Plug-In

This functionality is only available if the MSAA Open Applications plug-in (tcMSAAOpenApp.pls) is installed. Before testing your FoxPro application, make sure that this plug-in is installed by clicking File | Install Extension on TestComplete's main menu.

Extensions Dialog

Configuring the FoxPro Application

In order to recognize the application’s windowed and non-windowed controls exposed by the IAccessible interface, TestComplete uses their accessibility properties. To simplify the recognition process, you can configure your FoxPro application so that the controls have specific values.

You can only set an object’s accessible name in FoxPro. The accessible name of an object is its Name property, which is used to address the object in the application code. By default, when you add controls to a form, FoxPro names them automatically. For example, the Textbox control is named Text1. You can give controls more specific names so that it is easier to find them in the application’s object hierarchy and easier to use them in your scripts. To do this:

  1. Open your FoxPro project.
  2. In the Form Designer, open the forms that contain the controls you want to edit.
  3. Right-click the control and select Properties from the context menu to display the Properties window.
  4. Switch to the Other page.
  5. Select Name property. In the property settings box, specify the name for the control.
  6. Save changes and recompile your FoxPro application.


Repeat steps 2-5 for all controls that you will use when testing your application.

Configuring the TestComplete Project

Before testing your FoxPro application you have to configure the TestComplete project:

  1. Launch TestComplete and create a new test project that only contains the Script project item.
  2. Right-click the project node in the Project Explorer panel and select Edit | Properties from the context menu. This opens the project editor in the Workspace panel and displays the Properties page.
  3. Select the MSAA Open Applications group on the left of the page. TestComplete will display the List of Accepted Windows: on the right. This list contains window's class names, whose properties will be accessed via TestComplete’s MSAA engine.
  4. Select the check box corresponding to the asterisk (*) class name. This allows TestComplete to use the MSAA engine to expose methods and properties of any existing window.
  5. Save all project changes by clicking File | Save All from TestComplete’s main menu.


Testing FoxPro Application

Before creating the test script, you need to make sure that TestComplete has access to the application’s internal objects, methods and properties exposed by the IAccessible interface.

  1. Launch your FoxPro application.
  2. Switch to TestComplete’s Object Browser.
  3. In the Object Browser tree, expand the node corresponding to your FoxPro application. Objects that are accessible via the IAccessible interface are shown with the icon. The name of each node implementing the IAccessible interface consists of a prefix that specifies the element’s accessible role (for example, table or editable_text) followed by an underscore and the element’s accessible name. If the element does not have an accessible name, TestComplete names it.
  4. Explore your FoxPro application in the Object Browser to find the names of the controls that you are going to use in your scripts.


Now you can write the test script for your application. In the script, use the MSAAObject and WaitMSAAObject methods to address the application’s internal objects. The internal properties and methods of these objects are displayed in the Object Browser's Properties and Methods pages.

You can find more help on working with objects exposed by the IAccessible interface by reading the Working With Windows Implementing the IAccessible Interface help topic. You can access it by the help file's table of contents (Using TestCompleteTesting With TestCompleteMSAA Support).