Testing PowerBuilder Applications With TestComplete 4
Currently, PowerBuilder applications are closed to TestComplete. In other words, TestComplete does not have access to internal objects, methods and properties of these applications. You can test these applications by simulating mouse clicks, keystrokes, using low-level procedures, manual tests as well as other means provided by TestComplete for testing black-box applications.
However, since PowerBuilder supports Microsoft Active Accessibility, you can work with application objects using TestCompletes MSAA engine. It provides access to application internals exposed through Microsoft Active Accessibility. So, the MSAA engine makes PowerBuilder applications more open in comparison to traditional black-box apps.
Testing PowerBuilder Applications With TestComplete 4
TestComplete currently treats applications created with PowerBuilder as closed applications because it can not access the applications internal objects, methods and properties. To test these applications you would have to test them as black-box applications by simulating mouse clicks and keystrokes using low-level procedures, manual tests and various other features provided by TestComplete.
However, not all PowerBuilder application objects are closed to TestComplete since PowerBuilder supports Microsoft Active Accessibility. TestCompletes MSAA engine provides access to application internals exposed through Microsoft Active Accessibility. The MSAA engine makes PowerBuilder applications open in comparison to traditional black-box applications. Since PowerBuilder application windows and controls support Microsoft Active Accessibility, you can access and use the applications internal objects, methods and properties that are exposed by the IAccessible interface. These methods and properties are displayed in TestCompletes Object Browser just like any open application and can be used in your scripts.
In this blog entry, I will demonstrate how to retrieve data from the DataWindow non-visual component of an application created with PowerBuilder 10 or later.
Installing the MSAA Plug-In
TestComplete includes a special MSAA Open Applications plug-in that provides access to objects, methods and properties exposed by Microsoft Active Accessibility. To test PowerBuilder applications, you need to install this plug-in into TestComplete in order to view an applications internal objects, methods and properties. You can install the plug-in during TestComplete's installation or at any later time. To check whether the plug-in is installed, launch TestComplete and select File | Install Extensions from the main menu. In the subsequent Extensions dialog, make sure that the MSAA Open Applications plug-in is selected: Extensions Dialog
If the plug-in is not listed in the dialog, run the TestComplete installation program in Modify mode and install the plug-in.
Creating a Sample PowerBuilder Application
To create a sample PowerBuilder application:
Now that your project's contents are set, open the window_main window in the Window Painter and place a DataWindow Control to window_main: Layout View
In the Properties window you can specify PowerBuilder controls accessibility property values: AccessibleName, AccessibleDescription and AccessibleRole. These properties are used to address the control in TestComplete. Setting specific values for these properties will help you find the controls in the Object Browser easier. Although, you can leave the default values since TestComplete will still be able to address the objects. Accessibility Properties Highlighted
Save the changes and compile your PowerBuilder application. Now your application is ready for testing and you can configure the TestComplete project.
Configure a TestComplete Project
To start testing with TestComplete first you have to configure a project:
Testing the PowerBuilder Application
You are now ready to perform a test with your PowerBuilder Application. To start the test:
- Launch your PowerBuilder application.
- Switch to TestCompletes Object Browser.
- Expand the node corresponding to the PowerBuilder application (Process("msaaconnection")) to make sure that the test engine has access to the applications internal objects, methods and properties. These elements are accessed through MSAA. In the image below, the Object Browser displays the object tree of the PowerBuilder 10 application. The selected tree node corresponds to the DataWindow Control. Child elements of this control are displayed as child nodes. The name of each node contains a prefix (mb, sb, text and others) that specifies the elements role. The prefix is followed by an underscore and the accessible name. If an element does not have an accessible name, TestComplete forms the name itself:
The following JScript code demonstrates how you can access PowerBuilder application elements from your script. The
GetObjectByName function is used to obtain an element by its name and index. The
Main function iterates through all application elements and posts DataWindow element values to the test log.
This script, executed for my sample application, produced the following log. Your log will look different since we are using different databases. TestComplete Log
As you can see, the script can retrieve values from DataWindow controls. Using TestCompletes MSAA engine you can retrieve property values of other PowerBuilder application controls.