Accessing a FoxPro Application's Internal Objects
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 applications 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
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 applications 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 objects 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 applications object hierarchy and easier to use them in your scripts. To do this:
- Open your FoxPro project.
- In the Form Designer, open the forms that contain the controls you want to edit.
- Right-click the control and select Properties from the context menu to display the Properties window.
- Switch to the Other page.
- Select Name property. In the property settings box, specify the name for the control.
- 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:
- Launch TestComplete and create a new test project that only contains the Script project item.
- 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.
- 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 TestCompletes MSAA engine.
- 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.
- Save all project changes by clicking File | Save All from TestCompletes main menu.
Testing FoxPro Application
Before creating the test script, you need to make sure that TestComplete has access to the applications internal objects, methods and properties exposed by the IAccessible interface.
- Launch your FoxPro application.
- Switch to TestCompletes Object Browser.
- 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 elements accessible role (for example, table or editable_text) followed by an underscore and the elements accessible name. If the element does not have an accessible name, TestComplete names it.
- 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
WaitMSAAObject methods to address the applications 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).