前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PowerBuilder的搜索

Testing PowerBuilder Applications with TestComplete Resources || Blog || Products Products For Development Collaborator Code Review & Document Review ALMComplete Lifecycle Management AQtime Pro Performance Profiling Automated Build Studio Software Release Management SoapUI Pro API Testing - SoapUI Pro All Development For Testing & QA TestComplete Automated Testing QAComplete Test Management LoadUIWeb Pro Load Testing AQtime Pro Performance Profiling LoadUI Pro API Load Testing All Testing & QA For Web Monitoring AlertSite Website Monitoring AlertSite API Monitoring Free API Monitoring AlertSite Insite Internal Website Monitoring Support Support when you need it SmartBear technical representatives are always ready to help with your product needs. Browse our support portal Know what you're looking for? Downloads User Guides How To Tutorials Technical Articles Screencasts/Videos General support Forums Troubleshooter FAQs Product Versions Community Blog Home > SmartBear Software Support > Loading&hellip; TestComplete/viewarticle/63445/ General Information/viewarticle/63445/ Using Help System/viewarticle/55799/ Getting Started Tutorial/viewarticle/56246/ Using TestComplete/viewarticle/57875/ Testing Types/viewarticle/62721/ Applications Testing/viewarticle/62606/ About Open Applications/viewarticle/55489/ Testing .NET Applications/viewarticle/56853/ Testing WPF Applications/viewarticle/55216/ Testing Visual C++ Applications/viewarticle/60932/ Testing Visual Basic Applications/viewarticle/62841/ Testing Web Applications/viewarticle/55054/ Testing Web Services/viewarticle/56243/ Testing Delphi Applications/viewarticle/56053/ Testing C++Builder Applications/viewarticle/56052/ Testing Java Applications/viewarticle/57396/ Testing Flash and Flex Applications/viewarticle/55427/ Testing JavaFX Applications/viewarticle/55495/ Testing AIR Applications/viewarticle/55626/ Testing Windows Store Applications/viewarticle/56253/ Testing Silverlight Applications/viewarticle/55409/ Testing ClickOnce Applications/viewarticle/55757/ Testing Qt Applications/viewarticle/55399/ Testing Android Applications/viewarticle/56199/ Testing Mobile Web Applications/viewarticle/56249/ Testing PowerBuilder Applications/viewarticle/56890/ Testing PowerBuilder Applications with TestComplete/viewarticle/62761/ Testing PowerBuilder .NET Applications with TestComplete/viewarticle/62760/ Testing FoxPro Applications/viewarticle/56889/ Testing Microsoft Access Applications/viewarticle/56886/ Testing Microsoft InfoPath Forms/viewarticle/56887/ Testing 64-bit Applications/viewarticle/55272/ Testing Unicode Applications/viewarticle/55018/ Testing Console Applications/viewarticle/55407/ Working With Application Objects and Controls/viewarticle/55815/ Samples and Tutorials/viewarticle/56239/ References/viewarticle/57878/ Other Tools That Help You Test Better/viewarticle/63442/ TestComplete Licensing Guide/viewarticle/63451/ color:White;background-color:#6DA1DA; Updated: 12/27/2013 Applies To: TestComplete 10 Rating: No votes Click to rate: Full-Screen mode &rarr; Testing PowerBuilder Applications Select language for code samples Testing PowerBuilder Applications with TestComplete See Also This topic describes how you can perform functional testing of applications created in Sybase PowerBuilder Classic 12.0. The following sections will explain how to prepare your PowerBuilder application for testing and set up a TestComplete project. The sample script in the end of the topic provides an example of how to simulate various actions over a PowerBuilder application’s user interface and obtain data from a DataWindow control. General Notes Configuring PowerBuilder Application Configuring TestComplete Project Exploring the Application in the Object Browser Example Possible Problems Testing PowerBuilder .NET Applications General Notes In order for TestComplete to simulate user actions over an application’s controls, it needs to have access to them. If you explore a PowerBuilder application in the Object Browser (for example, the PB Examples application that is shipped with PowerBuilder), you can see that by default TestComplete can access most controls on the application’s forms, except for DataWindow controls (the Window("pbdw100", "", 1) object on the image below). The reason for this is that DataWindow is a non-standard control. So, to interact with DataWindow controls and retrieve data from them you need a way to make DataWindow elements visible to TestComplete. Since applications created in PowerBuilder Classic 12.0 support Microsoft Active Accessibility (MSAA), you can access DataWindow elements using TestComplete’s MSAA engine. This engine is included in the Microsoft Active Accessibility Support plug-in (this plug-in is installed and enabled automatically as part of TestComplete’s Desktop module). In order for the MSAA engine to provide access to DataWindow elements, you need to add the DataWindow control’s class name to the list of objects that the engine will expose. This list is individual for each TestComplete projects and can be customized in the project’s MSAA Options. Note also, that in order to recognize controls (both windowed and non-windowed) exposed via Active Accessibility, TestComplete uses their accessible names and roles (see Addressing Windows, Controls and Objects of MSAA Open Applications). To simplify the recognition process, you can modify your PowerBuilder application so that the controls you are going to access from tests have specific accessible names. The rest of this topic provides detailed instructions on how to configure the tested PowerBuilder application and TestComplete’s MSAA engine. For more information on testing applications that support Active Accessibility, see Using Microsoft Active Accessibility. Configuring PowerBuilder Application To specify accessibility properties for controls of your PowerBuilder application, do the following: Open your PowerBuilder project. Open the windows with the desired controls in PowerBuilder’s Window Painter. In the Properties window, switch to the Other tabbed page. Here you can specify accessibility properties of the desired PowerBuilder application controls: AccessibleName, AccessibleDescription and AccessibleRole: TestComplete uses the AccessibleName and AccessibleRole properties to identify and address controls. You can leave the AccessibleRole property unchanged, but it is recommended that you specify the AccessibleName property value for controls. This will make it easier for you to identify the controls in the recorded tests and to address controls when you create tests manually. Save the changes made and re-build your PowerBuilder application. Configuring TestComplete Project To enable TestComplete’s MSAA engine to expose internal elements of DataWindow controls in the tested PowerBuilder application, you need to configure the project’s MSAA settings: Open your TestComplete project. Right-click the project node in the Project Explorer panel and select Edit | Properties from the context menu. This will open the project editor in the Workspace panel and display the Properties page. Select the Open Applications | MSAA group on the left of the page. TestComplete will display the list of MSAA properties on the right. This list contains windows class names and their properties will be accessed via TestComplete’s MSAA engine. To make the MSAA engine provide access to DataWindow elements, add the pbdw* item to the List of accepted windows: Enabling the “*” item will make the MSAA engine expose internal elements of any window and control. Select File | Save All from TestComplete’s main menu or press Ctrl+S to save the changes. Exploring the Application in the Object Browser After you have set up the MSAA options, TestComplete has access to DataWindow elements. These elements are displayed in the Object Browser with the icon. The name of each MSAA node consists of its type name, which indicates the element’s accessible role, and the element’s accessible name. For example, on the following figure the Panel("Customers") object on the image below corresponds to a DataWindow control with the accessible name of “Customers” and its child objects correspond to DataWindow cells: To determine which name a particular object has in the Object Tree, you can use TestComplete’s target glyph: Click the ?Display Object Spy button on the Tools toolbar. Activate your PowerBuilder application. In the Object Spy window, click the Drag the target to point to the object icon, drag its glyph () to the desired application window or control, wait until the red frame appears around the object and release the mouse button. TestComplete will display the object’s properties, methods and events in the Object Spy window. The object’s full name, which is used to address the object in the script, is specified by the FullName property. You can right-click the value of the property in the Object Spy window, select Copy from the context menu and then paste the copied object name to the script in the Code Editor. For more information about how TestComplete addresses objects exposed by the MSAA engine, see Addressing Windows, Controls and Objects of MSAA Open Applications. Example The sample script below demonstrates how you can simulate user actions over controls in PowerBuilder applications and retrieve data from DataWindow controls. The script works with the PB Examples sample application that is shipped with PowerBuilder 12 and can be found in the <PowerBuilder 12>\Code Examples\Example App\ folder. The application must be running before you launch the script. This example also requires that the List of accepted windows in the project’s MSAA Options contains the pbdw* item and that the Work with MSAA objects in mode compatible with TestComplete 6 and earlier option in the same category is turned off. Show Example Show ExampleHide Example VBScriptCopy Code Sub Main??Dim p, tabExamples, tvExamples, frmSFExample, grid, cells, i??' Obtain the PB Examples process??Set p = Sys.Process("examples")??' If you run the application from PowerBuilder, use the following code:??' Set p = Sys.Process("examples")??' Launch the "Sort & Filter" example??Set tabExamples = p.Window("FNWND3100", "PowerBuilder 12. Code Examples").Window("PBTabControl32_100", "", 2)??tabExamples.ClickTab("Examples")??Set tvExamples = tabExamples.Window("FNUDO3100", "Examples").Window("PBTreeView32_100")??tvExamples.DblClickItem("|PowerBuilder Examples|DataWindows|Runtime Modification|Sort & Filter")??' Obtain the example's main form??Set frmSFExample = p.Window("FNWND3100", "Sort & Filter Example")??' Filter the data: Display customers from California only??frmSFExample.Window("ComboBox", "", 2).ClickItem("state")??frmSFExample.Window("ComboBox", "", 4).ClickItem("=")??frmSFExample.Window("ComboBox", "", 1).ClickItem("CA")??frmSFExample.Window("Button", "&Filter").Click??' Post information from the DataWindow to the test log??Set grid = frmSFExample.Window("pbdw100")??' Get the number of cells in the DataWindow??cells = grid.FindAllChildren("ObjectType", "Edit", 1)??For i = 1 To UBound(cells)????Log.AppendFolder(grid.Edit(i+1).Text & " " & grid.Edit(i+4).Text)????Log.Message("Customer ID: " & grid.Edit(i).Text)????Log.Message("Company Name: " & grid.Edit(i+7).Text)????Log.Message("Phone: " & grid.Edit(i+3).Text)????Log.Message("Address: " & grid.Edit(i+2).Text)????Log.Message("City: " & grid.Edit(i+5).Text)????Log.Message("ZIP: " & grid.Edit(i+6).Text)????Log.PopLogFolder????i = i + 8??NextEnd?Sub JScriptCopy Code function Main() {??var p, tabExamples, tvExamples, frmSFExample, grid, cells, i;??// Obtain the PB Examples process??p = Sys.Process("examples");??// If you run the application from PowerBuilder, use the following code:??// p = Sys.Process("Pb100");??// Launch the "Sort & Filter" example??tabExamples = p.Window("FNWND3100", "PowerBuilder 12. Code Examples").Window("PBTabControl32_100", "", 2);??tabExamples.ClickTab("Examples");??tvExamples = tabExamples.Window("FNUDO3100", "Examples").Window("PBTreeView32_100");??tvExamples.DblClickItem("|PowerBuilder Examples|DataWindows|Runtime Modification|Sort & Filter");??// Obtain the example's main form??frmSFExample = p.Window("FNWND3100", "Sort & Filter Example");??// Filter the data: Display customers from California only??frmSFExample.Window("ComboBox", "", 2).ClickItem("state");??frmSFExample.Window("ComboBox", "", 4).ClickItem("=");??frmSFExample.Window("ComboBox", "", 1).ClickItem("CA");??frmSFExample.Window("Button", "&Filter").Click();??// Post information from the DataWindow to the test log??grid = frmSFExample.Window("pbdw100");??// Get the number of cells in the DataWindow??cells = grid.FindAllChildren("ObjectType", "Edit", 1);??cells = VBArray(cells).toArray();??for (i = 1; i < cells.length; i += 8)??{????Log.AppendFolder(grid.Edit(i+1).Text + " " + grid.Edit(i+4).Text);????Log.Message("Customer ID: " + grid.Edit(i).Text);????Log.Message("Company Name: " + grid.Edit(i+7).Text);????Log.Message("Phone: " + grid.Edit(i+3).Text);????Log.Message("Address: " + grid.Edit(i+2).Text);????Log.Message("City: " + grid.Edit(i+5).Text);????Log.Message("ZIP: " + grid.Edit(i+6).Text);????Log.PopLogFolder();??} } DelphiScriptCopy Code procedure Main;var p, tabExamples, tvExamples, frmSFExample, grid, cells, i;begin??// Obtain the PB Examples process??p := Sys.Process('examples');??// If you run the application from PowerBuilder, use the following code:??// p := Sys.Process('examples');??// Launch the 'Sort & Filter' example??tabExamples := p.Window('FNWND3100', 'PowerBuilder 12. Code Examples').Window('PBTabControl32_100', '', 2);??tabExamples.ClickTab('Examples');??tvExamples := tabExamples.Window('FNUDO3100', 'Examples').Window('PBTreeView32_100');??tvExamples.DblClickItem('|PowerBuilder Examples|DataWindows|Runtime Modification|Sort & Filter');??// Obtain the example's main form??frmSFExample := p.Window('FNWND3100', 'Sort & Filter Example');??// Filter the data: Display customers from California only??frmSFExample.Window('ComboBox', '', 2).ClickItem('state');??frmSFExample.Window('ComboBox', '', 4).ClickItem('=');??frmSFExample.Window('ComboBox', '', 1).ClickItem('CA');??frmSFExample.Window('Button', '&Filter').Click;??// Post information from the DataWindow to the test log??grid := frmSFExample.Window('pbdw100');??// Get the number of cells in the DataWindow??cells := grid.FindAllChildren('ObjectType', 'Edit', 1);??for i := 1 to VarArrayHighBound(cells, 1) do??begin????Log.AppendFolder(grid.Edit(i+1).Text + ' ' + grid.Edit(i+4).Text);????Log.Message('Customer ID: ' + grid.Edit(i).Text);????Log.Message('Company Name: ' + grid.Edit(i+7).Text);????Log.Message('Phone: ' + grid.Edit(i+3).Text);????Log.Message('Address: ' + grid.Edit(i+2).Text);????Log.Message('City: ' + grid.Edit(i+5).Text);????Log.Message('ZIP: ' + grid.Edit(i+6).Text);????Log.PopLogFolder;????i := i + 8;??end;end; C++Script, C#ScriptCopy Code function Main() {??var p, tabExamples, tvExamples, frmSFExample, grid, cells, i;??// Obtain the PB Examples process??p = Sys["Process"]("examples");??// If you run the application from PowerBuilder, use the following code:??// p = Sys["Process"]("Pb100");??// Launch the "Sort & Filter" example??tabExamples = p["Window"]("FNWND3100", "PowerBuilder 12. Code Examples")["Window"]("PBTabControl32_100", "", 2);??tabExamples["ClickTab"]("Examples");??tvExamples = tabExamples["Window"]("FNUDO3100", "Examples")["Window"]("PBTreeView32_100");??tvExamples["DblClickItem"]("|PowerBuilder Examples|DataWindows|Runtime Modification|Sort & Filter");??// Obtain the example's main form??frmSFExample = p["Window"]("FNWND3100", "Sort & Filter Example");??// Filter the data: Display customers from California only??frmSFExample["Window"]("ComboBox", "", 2)["ClickItem"]("state");??frmSFExample["Window"]("ComboBox", "", 4)["ClickItem"]("=");??frmSFExample["Window"]("ComboBox", "", 1)["ClickItem"]("CA");??frmSFExample["Window"]("Button", "&Filter")["Click"]();??// Post information from the DataWindow to the test log??grid = frmSFExample["Window"]("pbdw100");??// Get the number of cells in the DataWindow??cells = grid["FindAllChildren"]("ObjectType", "Edit", 1);??cells = VBArray(cells)["toArray"]();??for (i = 1; i < cells["length"]; i += 8)??{????Log["AppendFolder"](grid["Edit"](i+1)["Text"] + " " + grid["Edit"](i+4)["Text"]);????Log["Message"]("Customer ID: " + grid["Edit"](i)["Text"]);????Log["Message"]("Company Name: " + grid["Edit"](i+7)["Text"]);????Log["Message"]("Phone: " + grid["Edit"](i+3)["Text"]);????Log["Message"]("Address: " + grid["Edit"](i+2)["Text"]);????Log["Message"]("City: " + grid["Edit"](i+5)["Text"]);????Log["Message"]("ZIP: " + grid["Edit"](i+6)["Text"]);????Log["PopLogFolder"]();??} } Possible Problems On some computers running under 64-bit editions of Windows XP or Windows Server 2003, TestComplete may be unable to record user actions over PowerBuilder applications properly. The problem can be caused by printer drivers installed in the operating system. To solve the problem and use TestComplete to test your PowerBuilder application on these operating systems, try uninstalling the printer drivers. Testing PowerBuilder .NET Applications Since PowerBuilder 12.0, the PowerBuilder utility is divided into PowerBuilder Classic 12.0 and PowerBuilder .NET 12.0. The approach above describes how you can test applications created in PowerBuilder Classic 12.0. However, there is another approach that you should use when testing applications created in PowerBuilder .NET 12.0 with TestComplete. To learn more, see Testing PowerBuilder .NET Applications with TestComplete. See also Testing PowerBuilder Applications | Testing PowerBuilder .NET Applications with TestComplete | Using Microsoft Active Accessibility | Supported Development Tools ? 2014 SmartBear Software. All rights reserved. Send feedback on this document