TestComplete脚本样例

学习每一个自动化测试工具的最佳途径就是参考帮助文档以及研究工具附带的样例脚本,下面列出了所有TestComplete中附带脚本例子:

 

 

 

The <TestComplete Samples>\Scripts folder holds examples of TestComplete scripts (that is, script procedures or functions that can be executed in TestComplete).

 

On Windows 7, Windows Vista and Windows Server 2008, TestComplete samples are located in the <Users>\Public\Documents\TestComplete 7 Samples folder. On other operating systems, the samples reside in the <Documents and Settings>\All Users\Documents\TestComplete 7 Samples folder.

The samples are listed below in alphabetical order.

ADO(如何在脚本中访问ADO接口)

Illustrates how to work with databases from scripts through the ADO interface. The script connects to a database table using ADO, saves the data of the table to an XML file, runs the application (Borland’s mastapp) that lets you modify the table’s data, performs some changes in the table using the application, saves the current data of the table to another XML file, compares these XML files and posts the differences to the test log.

<TestComplete Samples>\Scripts\ADO

Aqtime(如何与AQTime整合)

Illustrates the integration between TestComplete and AQtime. AQtime must be installed on your computer. The script creates a new AQtime project for the tested application (Borland’s mastapp), selects the Coverage profiler, starts profiling, performs user actions over the tested application, obtains profiling results, exports the results to an XML file and closes AQtime.

<TestComplete Samples>\Scripts\AQtime

Note:

To run this sample in Windows 7, Windows Vista or Windows Server 2008, TestComplete must be running under an administrator account. See also Testing Applications With TestComplete Under Windows Vista and Later Operating Systems.

BDE(Borland数据库引擎BDE对象的使用)

Illustrates how to work with databases from scripts through the BDE object. The script connects to a database table using BDE, saves the data of the table to a file, runs the application (Borland’s mastapp) that lets you modify the table’s data, performs some changes in the table using the application, saves the current data of the table to another file, compares these files and posts the differences to the test log.

<TestComplete Samples>\Scripts\BDE

Checkpoints Samples(检查点的使用)

TestComplete includes a number of samples that demonstrate how to perform various kinds of checkpoints:

Database Table Checkpoints(数据表检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\DatabaseTableCheckpoints\

File Checkpoints(文件检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\FileCheckpoints\

Object Checkpoints(对象检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\ObjectCheckpoints\

Property Checkpoints(属性检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\PropertyCheckpoints\

Region Checkpoints(区域检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\RegionCheckpoints\

Table Checkpoints(表格检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\TableCheckpoints\

WebAccessibility Checkpoints(Web可访问性检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\WebAccessibilityCheckpoints\

WebComparison Checkpoints(Web对比检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\WebComparisonCheckpoints\

Web Service Checkpoints(Web Service检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\WebServiceCheckpoints\

XML Checkpoints(XML检查点):

<TestComplete Samples>\Scripts\CheckpointsSamples\XMLCheckpoints\

Create Manual Test(手工测试的建立)

Demonstrates how you can create manual tests from scripts by importing test instructions from a Microsoft Word document or an Access database. The script demonstrates how to parse the file contents, add test steps, specify their properties and save the created test to a file. You can then add the manual test from this file to the desired TestComplete project. See also Creating Manual Tests From Scripts.

Create Manual Test Using .doc File:

<TestComplete Samples>\Scripts\CreateManualTest\Create Manual Test Using .doc File\

Create Manual Test Using .mdb File:

<TestComplete Samples>\Scripts\CreateManualTest\Create Manual Test Using .mdb File\

DbgServices(使用DbgServices对象,可以跟踪被测试程序的事件、异常等信息)

Illustrates how you can test your applications using the DbgServices object. The script checks whether the DbgServices object will trace events and exceptions, launches the tested application, runs the application’s code that raises exceptions, and finally collects information on the occurred events and raised exceptions in the test log.

Application:

<TestComplete Samples>\Scripts\DbgServices\Application

TestComplete project suite:

<TestComplete Samples>\Scripts\DbgServices

DDT(数据驱动测试)

This sample is used by the Data-Driven Testing Tutorial that describes a step-by-step procedure of creating data-driven tests in TestComplete. The script tests the OrdersDemo application, which is used to configure a table of purchase orders. The script reads data from an Excel sheet and adds new records to the table.

Excel file and TestComplete project suite:

<TestComplete Samples>\Scripts\DDT

DDT&NameMapping(数据驱动测试,使用NameMapping)

Illustrates how to perform data-driven tests in TestComplete. See also Data-Driven Testing. The script tests the OrdersDemo application, which is used to configure a table of purchase orders. The script adds new records to the table and modifies existing ones. The data the script enters to table records are taken from different sources: a multidimensional array defined directly in the script, a comma-separated values (CSV) file that the script accesses via Scripting.FileSystemObject, a CSV file that the script accesses via ADO, a Microsoft Access database that the script accesses via ADO and an Excel file that the script accesses via ADO. In order to unify the testing of the language-specific implementations of the OrdersDemo application (there are versions written in Microsoft Visual C++, Microsoft Visual Basic, Borland Delphi and Borland C++Builder), the script uses custom object names. See Name Mapping.

Data:

<TestComplete Samples>\Scripts\DDT&NameMapping\Data

TestComplete project suite:

<TestComplete Samples>\Scripts\DDT&NameMapping

Distributed Testing (Network Suite Sample)分布式测试

Illustrates how to you can use distributed testing in TestComplete. See also Distributed Testing. The script makes a shared folder on the computer that runs the master project, then requests the names of two computers that will run the same slave project (it is located in that shared folder), and runs the test on all computers engaged in distributed testing synchronously and then asynchronously.

<TestComplete Samples>\Scripts\DistributedTesting\Master

<TestComplete Samples>\Scripts\DistributedTesting\Slave

dotNETBridge(通过dotNETBridge访问.NET程序集)

Illustrates how your scripts can call functions located in .NET assemblies. The script first tests basic .NET types (DateTime, Decimal and String), then calls methods of a user-defined assembly and finally calls methods of a user-defined executable.

Microsoft Visual Studio .NET 7.x solutions:

<TestComplete Samples>\Scripts\dotNETBridge\Application\UserApp\UserApp.sln

<TestComplete Samples>\Scripts\dotNETBridge\Application\UserClassLib\UserClassLib.sln

Microsoft Visual Studio 2005 solutions:

<TestComplete Samples>\Scripts\dotNETBridge\Application\UserApp\UserApp_VS2005.sln

<TestComplete Samples>\Scripts\dotNETBridge\Application\UserClassLib\UserClassLib_VS2005.sln

TestComplete project suite:

<TestComplete Samples>\Scripts\dotNETBridge

Events(TestComplete的事件处理机制)

Illustrates how to handle events with TestComplete scripts. The main script posts messages of different types to the test log, launches Windows Notepad, opens the About box and then closes it. Event handlers that are defined in the script perform additional actions once the corresponding events occur. For instance, the handler of the OnLogError event changes the priority of the posted message, while the handler of the OnUnexpectedWindow event saves the screenshot of Notepad’s About box, which TestComplete treats as an unexpected window.

<TestComplete Samples>\Scripts\Events

Grids(各种表格控件的处理)

Demonstrates how you can work with various grid controls in TestComplete: retrieve and modify grid data, search for a specific record, simulate clicks on cells, expand and collapse rows, sort grid data, iterate through cells and save the grid contents to an XML file. See also Working With Grids.

Borland TDBGrid:

<TestComplete Samples>\Scripts\Grids\Borland_TDBGrid\

Borland StringGrid:

<TestComplete Samples>\Scripts\Grids\Borland_TStringGrid\

Developer Express PropertyGrid:

<TestComplete Samples>\Scripts\Grids\DevExpress_PropertyGrid\

Developer Express QuantumGrid:

<TestComplete Samples>\Scripts\Grids\DevExpress_QuantumGrid\

Developer Express XtraGrid:

<TestComplete Samples>\Scripts\Grids\DevExpress_XtraGrid\

Developer Express XtraVerticalGrid:

<TestComplete Samples>\Scripts\Grids\DevExpress_XtraVerticalGrid\

Infragistics WinGrid:

<TestComplete Samples>\Scripts\Grids\Infragistics_WinGrid\

Swing JTable:

<TestComplete Samples>\Scripts\Grids\JTable\

Microsoft DataGrid .NET:

Application (Microsoft Visual Studio .NET project):

<TestComplete Samples>\Scripts\Grids\Microsoft_DataGrid\DataGridSample\DataGridSample.csproj

TestComplete project:

<TestComplete Samples>\Scripts\Grids\Microsoft_DataGrid\

Microsoft DataGridView:

Application (Microsoft Visual Studio 2005 project):

<TestComplete Samples>\Scripts\Grids\Microsoft_DataGridView\DataGridViewSample\DataGridViewSample.csproj

TestComplete project:

<TestComplete Samples>\Scripts\Grids\Microsoft_DataGridView\

Microsoft MFCPropertyGrid:

<TestComplete Samples>\Scripts\Grids\Microsoft_MFCPropertyGirdCtrl\

Microsoft PropertyGrid:

Application (Microsoft Visual Studio .NET project):

<TestComplete Samples>\Scripts\Grids\Microsoft_PropertyGrid\PropertyGridSample\PropertyGridSample\PropertyGridSample.csproj

Application (Microsoft Visual Studio 2005 project):

<TestComplete Samples>\Scripts\Grids\Microsoft_PropertyGrid\PropertyGridSample\PropertyGridSample2005\PropertyGridSample2005.csproj

TestComplete project:

<TestComplete Samples>\Scripts\Grids\Microsoft_PropertyGird\

QtTableWidget:

<TestComplete Samples>\Scripts\Grids\QtTableWidget\

Syncfusion Essential Grid (GridGroupingControl):

<TestComplete Samples>\Scripts\Grids\Syncfusion_EssentialGrid\

Xceed GridControl:

<TestComplete Samples>\Scripts\Grids\XceedDotNetGrid\

Note:

You can download more grid samples from http://www.automatedqa.com/downloads/testcomplete/samples/.

Hello(最简单的TestComplete脚本)

Illustrates basic TestComplete functionality: key presses, accessing windows and processes, working with menus, and so on. The script launches MSpaint and writes a simple text in it.

<TestComplete Samples>\Scripts\Hello

Load Testing(负载测试的例子)

Demonstrates how to create load tests: how to create virtual users, assign tasks to them, organize users into groups, and so on. See also Load, Stress and Scalability Testing.

Web pages:

<TestComplete Samples>\Load Testing\LoadTesting.url

<TestComplete Samples>\Load Testing\LoadTestingOrders.url

TestComplete project suites:

<TestComplete Samples>\Scripts\Load Testing\Basics

<TestComplete Samples>\Scripts\Load Testing\Events

<TestComplete Samples>\Scripts\Load Testing\RASDemo

To install load testing samples, Microsoft Internet Information Services (IIS) 5.0 or later must be installed on your computer. Also, to run these samples under Windows Vista or later operating systems, you should install the ISAPI Extensions feature of IIS. For step-by-step instructions, see Running Load Testing Samples Under Windows Vista and Later Operating Systems.

TestComplete also includes a sample that demonstrates how to perform load testing of web services. See below.

Low-Level Recorder(低级录制)

Illustrates how to call low-level procedures in your scripts and how to search for an image within another one. The script launches MSPaint and draws a definite text in it using a brush tool. Drawing individual letters in this text is performed by low-level procedures. In order to choose an appropriate tool, color and the type of lines the brush will draw, the script captures an image of MSPaint’s tool box and color box, searches for corresponding elements in these boxes (the script looks for template images that are stored in the project's Stores | Regions collection) and then clicks the found region.

<TestComplete Samples>\Scripts\LLRecorder

Manual Testing(手工测试)

Demonstrates how to use TestComplete’s manual testing feature: how to create and organize manual test steps, how to initiate test execution from scripts and how to use manual testing events.

<TestComplete Samples>\Scripts\ManualTesting

MSAgentDemo(微软的OLE对象Agent的使用)

Illustrates how to work with OLE objects from scripts and how you can create demonstrations using TestComplete. The script accesses MSAgent as an OLE Server and makes it perform certain actions (speak, move, make gestures, and so on).

<TestComplete Samples>\Scripts\MSAgentDemo

MSOffice(如何在TC中与Office交互)

Illustrates how you can work with Microsoft Office applications from scripts. These scripts demonstrate how to export data to Word, read data from Excel and Access and how to send e-mail using Outlook.

Access

<TestComplete Samples>\Scripts\MSOffice\<ScriptingLanguageName>\Access_<ScriptingLanguageName>

Excel

<TestComplete Samples>\Scripts\MSOffice\<ScriptingLanguageName>\Excel_<ScriptingLanguageName>

Outlook

<TestComplete Samples>\Scripts\MSOffice\<ScriptingLanguageName>\Outlook_<ScriptingLanguageName>

Word

<TestComplete Samples>\Scripts\MSOffice\<ScriptingLanguageName>\Word_<ScriptingLanguageName>

Note:

To run this sample in Windows 7, Windows Vista or Windows Server 2008, TestComplete must be running under an administrator account. See also Testing Applications With TestComplete Under Windows Vista and Later Operating Systems.

Object-Driven Testing(对象驱动测试的例子)

TestComplete includes two samples that demonstrate how to use the Object-Driven Testing approach:

Simple ODT

A simple example that creates classes and objects for testing Windows Notepad.

<TestComplete Samples>\Scripts\ObjectDrivenTesting\Simple ODT

ObjectDrivenTesting

Another example for testing Notepad. The project includes a class for each file, operation, and so on. The script also demonstrates how to use ODT classes in scripts.

<TestComplete Samples>\Scripts\ObjectDrivenTesting\ObjectDrivenTesting

OCR(OCR字符识别对象的使用)

Demonstrates how to use TestComplete’s optical character recognition feature in your tests. The script launches the tested application (which includes a list and a box that displays the text of the currently selected list item), searches for a list item (actually it searches for a rectangle by the text it holds), clicks the found list item and recognizes the text displayed in the box.

Application:

<TestComplete Samples>\Scripts\OCR\Application

TestComplete project suite:

<TestComplete Samples>\Scripts\OCR

Run Modes(运行模式的使用)

Demonstrates how you can modify run-mode parameters of tested applications from scripts.

<TestComplete Samples>\Scripts\RunModes

Storages(使用Storages对象访问XML文件、INI文件、注册表)

Illustrates how to read data from and write them to the Registry and INI, XML and binary files using the Storages object.

<TestComplete Samples>\Scripts\Storages

Test Log(如何写入各种测试日志)

Illustrates posting a variety of pictures and messages to the test log and organizing them as a hierarchy of folders in the test log.

<TestComplete Samples>\Scripts\Test Log

Unicode(演示如何测试多字节的Unicode软件)

Demonstrates how to test multibyte Unicode applications. The scripts launches MSpaint and writes text in Japanese.

<TestComplete Samples>\Scripts\Unicode\Japanese\Hello

UserForms(如何在脚本中使用UserForms)

Demonstrates how you can work with user forms in your projects:

<TestComplete Samples>\Scripts\UserForms

WebTest(Web功能测试、负载测试的例子)

Demonstrates how to perform typical operations for functional testing of web pages: processing the blocked content message, working with buttons, edit boxes, check boxes, radio buttons, text areas and tables, verifying links and processing modal windows.

Web pages:

<TestComplete Samples>\Scripts\WebTest

TestComplete project suite:

<TestComplete Samples>\Scripts\WebTest\TCProject

Web&NameMapping(Web功能测试、负载测试的例子,使用NameMapping)

Demonstrates how to create NameMapping items for elements of a web page and perform typical operations for functional testing of this page.

Web pages:

<TestComplete Samples>\Scripts\WebTest

TestComplete project suite:

<TestComplete Samples>\Scripts\Web&NameMapping\TCProject

Web Services(WebServices功能测试和负载测试的例子)

TestComplete includes two samples that demonstrate testing of web services with TestComplete:

  • Demonstrates how you can perform functional testing of web services with TestComplete (how to prepare parameters, call web services’ methods from scripts and how to check the returned result by using script statements or checkpoints):

<TestComplete Samples>\Scripts\WebServices\Functional Testing

  • Demonstrates how you can perform load testing of web services with TestComplete (how to prepare requests and parse the response):

<TestComplete Samples>\Scripts\WebServices\Load Testing

These samples work with the web services, whose source files reside in the following folder:

<TestComplete Samples>\Web Services

Win32API(如何在TC中使用Win32函数)

Illustrates how to call Win32 API functions from TestComplete scripts. Namely, the script draws a simple text box on screen.

<TestComplete Samples>\Scripts\Win32API

 

 

 

 

 

 

另外,官方网站提供了表格控件的脚本例子 - Grid Samples:

 

ComponentOne True DBGrid Pro
ComponentOne VSFlexGrid Pro
Janus GridEX
Janus GridEX.v3
Rogue Wave Software Objective Grid
Syncfusion Essential Grid

 

下载地址:
http://www.automatedqa.com/downloads/testcomplete/samples/

 

 

 


 

posted on 2010-06-08 16:12  TIB  阅读(3452)  评论(0编辑  收藏  举报

导航