P. 1
Test Complete 7

Test Complete 7

|Views: 1,016|Likes:
Published by artifex16

More info:

Published by: artifex16 on May 16, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/05/2012

pdf

text

original

Sections

  • Foreword
  • 1.1 Introduction to TestComplete
  • 1.2 Who Should Read this Book
  • 1.3 How the Book is Organized
  • 2.2 Recording Your First Test
  • 2.3 Editing a Keyword Test
  • 2.4 Data Driven Keyword Testing
  • 3 Overview of Testing and TestComplete
  • 3.3 Types of Testing
  • 3.5 Your Most Important Test
  • 4.2 Menus and Toolbars
  • 4.3 Panels and Workspaces
  • 4.3.2.2 Object Properties Pane
  • 4.3.4.2 Enabling the Visualizer
  • 4.3.4.3 Working with Visualizer Images
  • 5 Projects and Suites
  • 5.3 New Project Wizard
  • 5.4 Hands on Lab: Create a Simple Test
  • 9.2 Supported Unit Testing Types
  • 9.4 Hands on Lab: Running a Unit Test
  • 10.2 Setting up a Manual Test Project
  • 10.3 Hands on Lab: Create a Manual Test
  • 10.4 Hands on Lab: Scripting and Manual Testing
  • 11 Basic Record and Playback
  • 11.3 Recording Toolbar Anatomy
  • 11.4 Hands on Lab: Perform a Basic Recording
  • 12.3 Hands on Lab: MS Paint Test
  • 13.5 Hands on Lab: Comparing File, Picture and a Property
  • 14.4 Hands on Lab: Modifying Recording for Data-Driven Testing
  • 15.2 General Events Definition
  • 15.4 Hands on Lab: Create Unexpected Window Handler
  • 16.3 Hands on Lab: Query Database
  • 17.4 Web Comparison Checkpoint
  • 17.5 Web Accessibility Checkpoint
  • 17.6 Finding Web Page Elements
  • 17.8 Hands on Lab: Work with Web Pages
  • 18.2 Testing against WSDL
  • 18.3 WebServices Checkpoint
  • 18.4 WebServices Testing Dialogs
  • 18.6 Hands on Lab: Testing a SOAP 1.2 Web Service
  • 19 HTTP Performance Testing
  • 19.2 Performance Testing Your Web Applications
  • 19.3 HTTP Load Testing Options
  • 19.6 Connections, Requests and Responses
  • 19.7 Visual Creation of a Load Test
  • 19.8 Analysis of the Test Log
  • 19.9 Modifying HTTP Traffic
  • 19.10 Hands on Lab: Working with HTTP Traffic
  • 20.2 Installing Remote Agent
  • 20.3 Running Remote Agent
  • 20.4 Configuring Remote Agent
  • 20.5 Hands on Lab: Working with Remote Agent for HTTP Load Testing
  • 24.3 Keyboard Handling in Recorder
  • 24.4 Global Shortcuts/Changing Keyboard Emulation

TestComplete 7 Made Easy
by Lino Tadros - Falafel Software Inc.

Welcome to TestComplete 7 Made Easy, the new guide to TestComplete 7, the award winning automated testing tool from AutomatedQA Corp. We hope you enjoy the book as much as we, at Falafel Software, enjoyed creating it.

TestComplete 7 Made Easy
Copyright © 2009 AutomatedQA Corp. - 2.0 Release
All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or mechanical, including photocopying, recording, taping, or information storage and retrieval systems - without the written permission of the publisher. Products that are referred to in this document may be either trademarks and/or registered trademarks of the respective owners. The publisher and the author make no claim to these trademarks. While every precaution has been taken in the preparation of this document, the publisher and the author assume no responsibility for errors or omissions, or for damages resulting from the use of information contained in this document or from the use of programs and source code that may accompany it. In no event shall the publisher and the author be liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or indirectly by this document. Printed: July 2009

Publisher AutomatedQA Corp. Authors Alain "Lino" Tadros Steve Trefethen

Special thanks to: All the team members at AutomatedQA worldwide for creating a magnificant piece of software in TestComplete 7. The authors also would lik e to thank the Falafel team members in Colorado, Texas and California for their feedback , guidance and recommendations on the subjects of the manual. Falafel would lik e to thank Mr. Derek Langone and Mr. Drew Wells for their trust and belief in the quality of Falafel Software's work .

Technical Editors Noel Rice Drew Wells Cover Designer Matt Kurvin Team Coordinator Lino Tadros Production Falafel Software Inc. Falafel would also lik e to thank Bobby Edgar, Adam Seeley, Andrew Westergren, Ashley Steenbruggen, Gerry McManus, Jim McDonough, Miles Kane, Nick Lord and of course the greatest Nick Olivo for their continuous support and friendship to the entire Falafel team. Last but not least, thank you to all our families for their support and patience while we wrote the book

4

TestComplete 7 Made Easy

Table of Contents
Foreword 10

Part I Introduction

12

1 Introduction to TestComplete ................................................................................................................................... 12 2 Who Should Read this Book ................................................................................................................................... 13 3 How the Book is Organized ................................................................................................................................... 13

Part II Keyword Testing

17

1 Objectives ................................................................................................................................... 17 2 Recording Your First Test ................................................................................................................................... 17 3 Editing a Keyword Test ................................................................................................................................... 20 4 Data Driven Keyword Testing ................................................................................................................................... 24 5 Summary ................................................................................................................................... 34

Part III Overview of Testing and TestComplete

36

1 Objectives ................................................................................................................................... 36 2 Terminology ................................................................................................................................... 36 3 Types of Testing ................................................................................................................................... 36 4 Before You Begin ................................................................................................................................... 37 5 Your Most Important Test ................................................................................................................................... 39 6 Summary ................................................................................................................................... 40

Part IV TestComplete IDE

42

1 Objectives ................................................................................................................................... 42 2 Menus and Toolbars ................................................................................................................................... 42 3 Panels and Workspaces ................................................................................................................................... 44
Project Explorer .......................................................................................................................................................... 44 Object Brow ser .......................................................................................................................................................... 47 Process Tree Pane ......................................................................................................................................................... 48 Object Properties Pane ......................................................................................................................................................... 50 Object Recognition ......................................................................................................................................................... 56 Introduction ......................................................................................................................................... 56 White-Box Applications ......................................................................................................................................... 57 Editor .......................................................................................................................................................... 59 Code Completion ......................................................................................................................................................... 59 Bookmarks......................................................................................................................................................... 60 Editor Options ......................................................................................................................................................... 61 Debugging......................................................................................................................................................... 63 Breakpoints ......................................................................................................................................... 63 Call Stack ......................................................................................................................................... 64 Locals ......................................................................................................................................... 65 Watch List ......................................................................................................................................... 66 Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Contents

5

.......................................................................................................................................................... 70 Visualizer Objectives ......................................................................................................................................................... 70 Enabling the Visualizer ......................................................................................................................................................... 70 Working w ......................................................................................................................................................... 71 ith Visualizer Images

4 Summary ................................................................................................................................... 73

Part V Projects and Suites

75

1 Objectives ................................................................................................................................... 75 2 Project Anatomy ................................................................................................................................... 75 3 New Project Wizard ................................................................................................................................... 79 4 Hands on Lab: Create a Simple Test ................................................................................................................................... 81 5 Summary ................................................................................................................................... 82

Part VI Project Items

84

1 Objectives ................................................................................................................................... 84 2 Project Items ................................................................................................................................... 84
Tested Applications .......................................................................................................................................................... 85

3 Summary ................................................................................................................................... 87

Part VII Test Log

89

1 Objective ................................................................................................................................... 89 2 Test Log ................................................................................................................................... 89 3 Emailing Result ................................................................................................................................... 90 4 LockEvents ................................................................................................................................... 91 5 Summary ................................................................................................................................... 92

Part VIII Name Mapping

94

1 Objectives ................................................................................................................................... 94 2 Map to Object ................................................................................................................................... 94 3 Highlight Objects ................................................................................................................................... 99 4 Mapping Dialog ................................................................................................................................... 101 5 Aliases in Scripts ................................................................................................................................... 102 6 Summary ................................................................................................................................... 102

Part IX Unit Testing

104

1 Objectives ................................................................................................................................... 104 2 Supported Unit Testing Types ................................................................................................................................... 104 3 NUnit Example ................................................................................................................................... 105 4 Hands on Lab: Running a Unit Test ................................................................................................................................... 108 5 Summary ................................................................................................................................... 110

Part X Manual Testing
Copyright © 2009 AutomatedQA Corp. - 2.0 Release

112

1 Objectives ................................................................................................................................... 112

5

6

TestComplete 7 Made Easy ................................................................................................................................... 112 2 Setting up a Manual Test Project 3 Hands on Lab: Create a Manual Test ................................................................................................................................... 113 4 Hands on Lab: Scripting and Manual Testing ................................................................................................................................... 120 5 Summary ................................................................................................................................... 124

Part XI Basic Record and Playback

126

1 Objectives ................................................................................................................................... 126 2 Overview ................................................................................................................................... 126 3 Recording Toolbar Anatomy ................................................................................................................................... 127
Adding Text .......................................................................................................................................................... 128 Changing Recording Types .......................................................................................................................................................... 129 Pausing .......................................................................................................................................................... 130 Stopping .......................................................................................................................................................... 130

4 Hands on Lab: Perform a Basic Recording ................................................................................................................................... 130 5 Summary ................................................................................................................................... 131

Part XII Low Level Procedure

133

1 Objectives ................................................................................................................................... 133 2 Recording ................................................................................................................................... 133 3 Hands on Lab: MS Paint Test ................................................................................................................................... 136 4 Summary ................................................................................................................................... 140

Part XIII Stores and Checkpoints

142

1 Objectives ................................................................................................................................... 142 2 Region Checkpoints ................................................................................................................................... 142 3 File ................................................................................................................................... 150 Comparisons 4 Object Comparisons ................................................................................................................................... 154 5 Hands on Lab: Comparing File, Picture and a Property ................................................................................................................................... 156 6 Summary ................................................................................................................................... 163

Part XIV Data-Driven Testing

165

1 Objectives ................................................................................................................................... 165 2 Overview ................................................................................................................................... 165 3 Modifying Scripts ................................................................................................................................... 165 4 Hands on Lab: Modifying Recording for Data-Driven Testing ................................................................................................................................... 167 5 Summary ................................................................................................................................... 171

Part XV Event Handling

173

1 Objectives ................................................................................................................................... 173 2 General Events Definition ................................................................................................................................... 173
OnLogError .......................................................................................................................................................... 175

3 Unexpected Windows ................................................................................................................................... 176

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

.............................................. 224 5 XML........................................................................................................................................................................................... ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 248 11 Summary ..... 226 Checkpoint 6 Hands on Lab: Testing a SOAP 1.. 212 Part XVIII WebServices Testing 214 1 Objectives .............................................. 183 3 Hands on Lab: Query Database ............................................. 214 2 Testing against WSDL .............................................. 200 Accessibility Checkpoint 6 Finding Web Page Elements ................................................................................................................ 251 Copyright © 2009 AutomatedQA Corp................................................................................................. 228 7 Summary ..................................................................................................................................................... 242 8 Analysis of the Test Log .................................................................................................................................................................................................................................... 239 6 Connections...................... 208 9 Summary ............................................................................................................. 203 7 Dynamic HTML .................................................................................................................................................................................................................................................................. 214 3 WebServices Checkpoint ...........2 Web Service ............................... 196 2 Web.............................................................0 Release 7 ................................................... 237 3 HTTP Load Testing Options ....................................................................................................... 237 2 Performance Testing Your Web Applications .................................................................................................................... 186 4 Summary ................................................................. 235 Part XIX HTTP Performance Testing 237 1 Objectives .................... 205 8 Hands on Lab: Work with Web Pages ... 197 Comparison Checkpoint 5 Web............................................................................................................................................................................................................. 241 7 Visual Creation of a Load Test ................................. 219 4 WebServices Testing Dialogs ....................................................................................................................................2.................................................................................................................................................................................................................................................................................................................................................................................Contents 7 ............................................................................................................................................. 244 9 Modifying HTTP Traffic .............................. 246 10 Hands on Lab: Working with HTTP Traffic ........................................................................................................................................................................................................................................................................................................................................................................................................ 181 Part XVI Working with Databases 183 1 Objectives ..................................... 197 4 Web......... 177 4 Hands on Lab: Create Unexpected Window Handler 5 Summary .................... Requests and Responses ....................................................................................................................................................................................................... 183 2 ADO................................. 196 Page Model 3 Naming Conventions ........................................................................................................................ 239 5 Recording ................................................................................................................................................................................. 194 Part XVII Web Page Testing 196 1 Objectives ................................................... 237 4 Cookie Handling ...............................................................

................................................................................................... 267 6 Setup ......................................................................................................................................................................................................................................................................................................................... 263 2 Network Suites ...................................... 253 3 Running Remote Agent ....................................................................................................................................................................................................................................................................................................................................................2.................................................................................................................................................................................................................................................................................................. 266 5 SynchPoints ........................................................................... 253 2 Installing Remote Agent ................ 286 3 Keyboard Handling in Recorder ......................................................................................... 292 2 Product Offerings ........................................ 280 2 Web. 278 4 Summary ......................................................................................... 261 Part XXI Distributed Testing 263 1 Objectives ......... 255 5 Hands on Lab: Working with Remote Agent for HTTP Load Testing ..........................................................................................................................................................................................0 Release .............................. 276 2 Creating ........................................................................................................................................................... 268 7 Summary ....................................................................................................................................................................................... 282 Page Part XXIV Cheat Sheet 284 1 Keyboard Shortcuts .......... 257 6 Summary ........ 253 4 Configuring Remote Agent ............................................................................................................................................................................................................................................ 265 4 Jobs/Tasks ............................................................... 288 Part XXV AutomatedQA 292 1 History ..................................................................................................................... 274 Part XXII User Forms 276 1 Objectives ................................................................................................................................................................................................................................................................................................ 276 3 Scripting ................................................................................. 287 4 Global Shortcuts/Changing Keyboard Emulation ............................................................................................................................. 263 3 Hosts ............................................................................................8 TestComplete 7 Made Easy Part XX Remote Agent 253 1 Objectives ...................... 278 Part XXIII Best Practices 280 1 General . 284 2 Code Completion ........................................................................................................... ................................................................................................................................................... 292 Part XXVI Professional Offering 298 Copyright © 2009 AutomatedQA Corp.............................

Contents 9 Index 300 Copyright © 2009 AutomatedQA Corp. .0 Release 9 .2.

and all the way to performance and load testing. founder and CEO of Falafel software. It’s easy to get started with TestComplete. It will definitely end up on the nightstands of all discerning TestComplete users. I can see that I was right… (again). but it also integrates all the other aspects of testing – from organizing your manual tests. there just aren’t that many experts in this field that have such experience and are also proficient and entertaining technical writers. Anyone writing a book on TestComplete had better have that kind of depth and experience. thank you for being my friend and knowing all there is to know about Ouzo. To be honest. too. but you also need a deep knowledge of your testing trade and software development best practices. I almost forgot – you can also write your scripts in any of several standard scripting languages. Thank you. of course. . That’s a lot of ground to cover. to doing unit testing and functional testing.2. my deepest respects go to Lino Tadros. Finally. for such a fine book and even more. but to take full advantage of everything that it has to offer you need not only to understand the built-in functionality.10 Foreword Foreword TestComplete is more than just a test automation tool – it does that. I just can’t think of anyone more appropriate for the task. for his expertise and his appreciation that all work and no fun is no way to go in life. When I first heard a new book on TestComplete was going to be written I crossed my fingers that the superstar team at Falafel Software would be involved in some way. This book is terrific. That’s already a daunting amount of functionality. Atanas Stoyanov Original Founder of AutomatedQA Copyright © 2009 AutomatedQA Corp. Lino. and then on top of that TestComplete supports multiple programming languages and platforms and it comes out of the box bundled with support for a long list of third party components. Now that I’ve reviewed the first manuscript. I strongly recommend it to everyone from novices just getting their feet wet.0 Release . to expert testers ready to go to the next level. and especially in testing.

Part I Introduction .

developers and nondevelopers. stress and scalability testing in one easy-to-use and totally integrated package at an affordable price. Even if you have no interest in automated testing procedures. It has been designed to free developers and QA departments from the massive drain on time and energy required by manual testing. It delivers automated functional. With TestComplete you and your team can implement comprehensive software testing strategies. Delphi Magazine Copyright © 2009 AutomatedQA Corp. [TestComplete] is a must-have tool for any software developer who believes in applying a rigorous testing methodology to his products. and the wide variety of scripting languages means you can work in whatever language you’re most comfortable with. regression. The ability to work with Visual C++. Once you start using TestComplete. Java. automated. TestComplete offers systematic. TestComplete is a full-featured environment for automated testing of Windows. C++Builder. . with superior support for . unit. contribute to your testing projects. you will be able to turn every test run into a key contribution to your overall development efforts. “automating the non-automatable” for maximum return on investment: “In my opinion. distributed and HTTP load. data-driven. manual. AutomatedQA’s TestComplete breaks this stereotype. It is equally oriented for testing 32-bit and 64-bit applications.NET. WPF (XAML) applications. and the work 100% productive. TestComplete tools and features let every member of your team. [TestComplete’s] fascinating ability to ‘automate the non-automatable’ is sure to find a use on your desktop!” Dave Jewell. Visual C++. and structured testing. WPF (XAML). web pages. the team confident.NET. With TestComplete you can also test PowerBuilder. Java and . . FoxPro. TestComplete is the ultimate solution to perform nightly tests and to help you get reliable daily builds of your software. Delphi. Java. Automated testing has long been thought critical for large software development organizations. object-driven. Visual Basic.0 Release .2. but is often considered to be too expensive and difficult to implement for smaller companies.12 TestComplete 7 Made Easy 1 1. Delphi. Access and other applications. C++Builder and web applications.NET applications means that you’re virtually getting several tools in one. no matter how technically savvy.1 Introduction Introduction to TestComplete About TestComplete Today automated testing plays a vital role in many software development projects. web servers and web services. Visual Basic. TestComplete will keep your projects on schedule and on spec.

TestExecute and TestRecorder. · You have used TestComplete and want to make your knowledge more comprehensive. 1. Name Mapping This section introduces Named Mappings and Aliases used to handle long object identifiers and to provide identifiers with meaningful names. AQtime. · You have worked in a QA environment and want to learn the AutomatedQA approach using TestComplete. how to build a "smoke test" and best practices for building durable tests that remain effective over time. including an exploration of the TestComplete environment and debugging basics. Projects and Suites This chapter covers the structure of a TestComplete project and the parts that make up the various testing functionality included in a project. Unit Testing Copyright © 2009 AutomatedQA Corp.Introduction 13 1.2. strategies for organizing and communicating your testing results. Test Log This section discusses the test log and the types of messages available in TestComplete. In this section you'll learn basic testing terminology.2 Who Should Read this Book You should read this book if: · You have never used TestComplete and want to learn what it's all about. AQdevTeam. the components of a Project. types of testing. TestComplete IDE This section introduces the basic tools you need to work effectively with TestComplete. This chapter discusses the difference between a Project and Project Suite. Overview of Testing and TestComplete This section discusses an approach to organizing your efforts for maximum return on your automatedtesting investment.0 Release . We will learn how to email the test log and also how to reduce the size of the test log.3 How the Book is Organized AutomatedQA This section includes a brief history of how AutomatedQA came into being and its mission. The section also includes a 1000 foot view of its award winning products TestComplete. Automated Build Studio. Project Items This section provides an overview of all project item types with additional detail on the Tested Application. . how to use the Project Wizard and how to create a simple test.

HTTP Performance Testing This section explores HTTP performance testing and other types of performance testing (e. Web Page Testing This section discusses how TestComplete represents web pages in the Object Browser.g. WebServices Testing This section demonstrates how to test a web service. creating web service types and calling complex methods. how to connect and run queries during a test. scalability).14 TestComplete 7 Made Easy This section discusses unit testing. This section also explains how to create a web service checkpoint. Event Handling This section explains how to respond to events that occur during testing and explains how to handle unexpected windows. . You will also learn about HTTP traffic recording and modification. Manual Testing This section looks at the structure of a TestComplete project and the parts that make up the various testing functionality included in a project. This section explains the connectivity options. stress. Stores and Checkpoints This section explores how to compare various testing input including visual areas of the screen. including how to import web service meta data.0 Release . load. how to navigate between web pages and how web checkpoints are used. the types of unit test frameworks supported by TestComplete and provides an example of using an NUnit unit test. Basic Record and Playback This section demonstrates how to perform basic record and playback tasks. calling simples methods. Data-Driven Testing This section covers how the Data Driven Testing plug-in consumes common data types.2. Low Level Procedure This section discusses TestComplete's Manual Testing features. Copyright © 2009 AutomatedQA Corp. This section also talks about strategies for locating and testing dynamic HTML elements. files and objects. how to construct a simple manual test using one of the provided sample applications and how to interact with manual tests from scripts. Working with Databases TestComplete includes general-purpose mechanisms for connecting to external databases.

shortcuts for Code Completion. Distributed Testing This section explains how tests are run on several computers at the same time.Introduction 15 Remote Agent Remote Agent is a tool that allows for the distribution of HTTP loads tests across a network of computers. Cheat Sheet Here you'll find a handy reference to TestComplete general keyboard shortcuts. Best Practices This section contains notes on best practices for testing in general and web pages in specific. User Forms This section demonstrates how to create user forms and manipulate them using scripts. . Copyright © 2009 AutomatedQA Corp. configure and run Remote Agent.2. how to change global shortcuts and how to change keyboard emulation. This section explains how to install. keyboard handling in the recorder.0 Release .

Part II Keyword Testing .

1 Keyword Testing Objectives In this section we'll take a look at the Keyword Testing features of TestComplete and you will learn how to: · Record Keyword tests · Add a checkpoint to a test · Convert a recorded test to a Data Driven Test The goal of Keyword Testing is to get developing testcases rapidly and in this chapter we'll do exactly that by developing a frequently requested testcase scenario using Data Driven testing. 2.2.Keyword Testing 17 2 2.2 Recording Your First Test For our first Keyword Test we'll start from scratch and record a simple data entry scenario using the Orders sample application. · In the Project Name field type: Keyword Copyright © 2009 AutomatedQA Corp. .0 Release . To get started: · Launch TestComplete · Click Record a New Test on the Start Page Record a New Test Test from the TestCom plete Start Page You will be prompted to create a new project.

perform the data entry below. Type: c:\Program Files\Automated QA\TestComplete 7\samples\open Apps\ordersdemo\c#\bin\debug\orders. Select Order | New Order to view the Order dialog 2. NOTE: This test was recorded using Windows Vista and may vary slightly if you're using an older version of Windows 1. You should now see the Orders sample application on screen Next we're going to perform the following data entry for our test: 1.2. end the recording and review the results. Press the Windows key to display the Start menu 2. .exe and press the Enter key (if you're using Windows XP you should select "Run" and use the Run dialog to start the application 3.18 TestComplete 7 Made Easy · Click Create Create a new Project As soon as you click Create the TestComplete main window is hidden and you'll see the recording toolbar: Recording a Keyword Test You are now recording a test! At this point. Increment the Quantity to 2 by clicking on the up arrow of the UpDown control Copyright © 2009 AutomatedQA Corp. we'll launch the Orders sample application.0 Release .

Type: "Jon Doe" in the Customer Name field.0 Release . "CA" in the State field and "95060" in the Zip field 4. Congratulations. click the Stop button on Recording toolbar (the blue square icon) and the TestComplete main window will reappear with the Keyword Test Editor open. Finally click the OK button to save the order Order dialog Now.Keyword Testing 19 3.2. "123 Easy" in the street field. . you've now recorded your first Keyword test! TestComplete should now look like this: Copyright © 2009 AutomatedQA Corp.

2. The editor consists of three pages (see the tabs at the bottom of the editor): · Test Steps (what you are currently looking at) · Variables .20 TestComplete 7 Made Easy Recorded Keyw ord Test 2. .0 Release .displays all of the steps of the test · Tabs to access the above editor pages Copyright © 2009 AutomatedQA Corp.used to specify values that are local to this test which can be passed from one operation to the next · Parameters .list all of the available operations you can perform in a Keyword test · Keyword Test Editor toolbar · Test Steps tree .3 Editing a Keyword Test Now that we've recorded our first Keyword test let's take a closer look at the Keyword Test Editor.used to specify parameters to the test The main parts of the Test Steps page are (moving clockwise from the top left): · Operations palette .

The Keyword Testing feature is very powerful and automatically leverages other features of TestComplete such as NameMapping. indent/outdent steps) · Edit a test description Editing Keyword Test Steps Copyright © 2009 AutomatedQA Corp. Aliases and TestedApps whereas in previous versions you had to configure each of these features manually prior to recording. .Keyword Testing 21 Notice as you read through the Test Steps we recorded it's easy to make sense of the various operations. Keyword Editor Toolbar From the Keyword Editor Toolbar you can: · Record a new test · Append operations to an existing test · Run a Keyword test · Add Variables and Parameters to the test · Manipulate Test Steps (move up/down.0 Release .2.

Type: property 3. The Test Steps tree supports many standard editing operations such as Undo.0 Release .exe At this point. Click the Search box at the top of the Operations palette 2. but not including the Run Tested Apps step 3. Click the first step of the test starting with Explorer 2. Redo. Copy and Paste available from the right click menu or main menu. we can delete the steps recorded to manually launch the Orders application in favor of using the Run TestedApp step.2. we'll add a Checkpoint operation to our test verifying the Total field on the Order dialog reflects the correct value (Quantity x Price). . deleting and editing steps. Select All. Next. Deleting Unnecessary Steps In our recorded test you'll notice TestComplete created a step reading "Run TestedApp Orders" and as you can see from the Project Explorer we now have an Orders subnode listed under TestedApps that it launches. you've completed your first test now. To add a checkpoint perform the following actions: 1. click the Run Test button on the toolbar and watch the results! Adding a Checkpoint Operation to a Test Next. Drag the item Property Checkpoint onto the Steps tree and drop it on the step where we set the Quantity to display the Create Property Checkpoint dialog Copyright © 2009 AutomatedQA Corp. As a result.22 TestComplete 7 Made Easy The Test Steps tree allows you to manipulate the test by adding. To verify this data we're going to use a Checkpoint operation and add it to our test after we've performed the data entry on the quantity field. we do just that and illustrate how easy it is to edit Keyword tests. To do that simply: 1. As is typical with recorded tests you'll want to review the results of the recording and tidy up the test by removing any unnecessary or redundant steps. Holding the Shift key down press the down arrow to highlight all of the steps up to. Cut. Press the Delete key to delete them from the test Delete com m ands used to start Orders.

2.. Change the Value to "200" (without quotes) and click Finish Your Keyword Test should now contain a step that looks like the If . . Type: "wText" (without quotes) into the Search edit box at the top right hand of the dialog and click Next 8. On the Create Property Checkpoint dialog click Next 7.. Then step below: Copyright © 2009 AutomatedQA Corp. Use the Finder Tool on the Create Property Checkpoint dialog to select the Total edit box on the Orders dialog 6. Click on the Orders application and select Order | New Order to display the Order dialog 5.Keyword Testing 23 4.0 Release .

24 TestComplete 7 Made Easy Keyw ord Test w ith If . Then operation inserted 2.0 Release . Here is what we need to do: · Create a CSV file with our test data · Add the CSV file to the Files Store · Modify the test to make it data driven Creating a CSV File Using Windows Notepad we can create a simple CSV text file that contains our test data..2. Copyright © 2009 AutomatedQA Corp.4 Data Driven Keyword Testing Building upon our existing Keyword test we can extend it to support Data Driven Testing and remove the instances where we have hard coded data entry. . notice that the first line of the file specifies the column names..

Keyword Testing

25

CSV file for data driven testing

To create this text file: 1. Start Windows Notepad 2. Enter the data pictured above 3. Save the file to disk as "names.csv" Adding the CSV File to the Files Store Next, we need to add this file to our Files Store. 1. From the TestComplete Project Explorer expand the Stores node, right click the Files subnode and select New Item

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

26

TestComplete 7 Made Easy

Add nam es.csv to the Files Store

2. On the Add File dialog locate names.csv and add it to the Files Store Modifying our Keyword Test to Perform Data Driven Testing Now that we have data to work with we can modify our test making it data driven. Here are the tasks we need to perform: · Initialize the CSVDriver · Create a loop that will iterate over all of the data · Indent our test steps to use the loop · Modify our data entry steps to use the data from the CSVDriver · Add a step to move to the next record Let's walk through each of these tasks: 1. Under Test Actions we'll add the Call Object Method operation by dragging it onto the Orders step:

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Keyword Testing

27

Adding the Call Object Method operation to our test

2. On the Call Object Method dialog enter "DDT" (without the quotes) as the object and click Next >

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

28

TestComplete 7 Made Easy

3. Select CSVDriver as the method and click Next >

4. Click the ellipsis (...) next to the Filename parameter, select Code Expression from the Mode dropdown and enter a Value of Files.FileNameByName('names.csv') then click OK

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Keyword Testing

29

5. Click the Finish button to complete the Call Object Method step Next, we'll add some logic to iterate over our data. 1. On the Operations palette under Statements select While Loop and drop it onto the Orders step.

2. The While Loop dialog will appear and click the ellipsis (...) under the Value1 column then select Code
Copyright © 2009 AutomatedQA Corp. - 2.0 Release

30

TestComplete 7 Made Easy

Expression from the Mode dropdown and enter a Value of: DDT.CurrentDriver.EOF() then click OK

3. Click on the edit box on under the Value2 column type false then click OK

Now, we need to nest our existing test steps under the While Loop step by indenting the remaining steps.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

. . We'll walk through changing the Customer data entry field and you can repeat the steps for the Street and Zip fields. Click the Orders step 2..) under the Value column to display the Edit Parameter dialog 3. Click the Indent button on the Keyword Editor Toolbar Next.2. Click the ellipsis (. 1.CurrentDriver.Keyword Testing 31 1. Value('name') then click OK then Finish Copyright © 2009 AutomatedQA Corp. Holding the Shift key down use the down arrow to multi-select the remaining test steps 3. On the Mode dropdown select Code Expression and change the Value to read DDT. Double click where it says "Jon Doe" to display the On-Screen Action dialog 2. we need to change our data entry steps to use values from the CSVDriver.0 Release .

we're almost done.. 1. CurrentDriver. At this point. .2.) to reflect the correct field. On the Operations palette select Test Actions then drag and drop the Run Code Snippet operation to the very bottom of our Keyword Test Copyright © 2009 AutomatedQA Corp.32 TestComplete 7 Made Easy 4. Repeat the same steps for the Street and Zip edit fields only changing the parameter passed to DDT.Value(.. the only thing remaining is to add a step that will move the CSV record pointer to the next row of data.0 Release .

For the code snippet use DDT. Finally.2. click the Indent button on the toolbar to indent our Run Code Snippet step and we're done! Your test should look like this: Copyright © 2009 AutomatedQA Corp.Next() then click OK 3.0 Release . .CurrentDriver.Keyword Testing 33 2.

34 TestComplete 7 Made Easy 2.5 Summary In this chapter we covered Keyword Testing including recording and editing Keyword Tests.0 Release . . You should be familiar with how to record Keyword tests and edit them using the Keyword Test Editor. Copyright © 2009 AutomatedQA Corp.2.

Part III Overview of Testing and TestComplete .

the Quality Assurance team · R&D .1 Overview of Testing and TestComplete Objectives In this section we'll discuss an approach to organizing your efforts to maximize the return on your automated testing investment.the code that will be tested using TestComplete 3.2. meaning that the tester can utilize the application under test the same way an end user would. 3. . Functional Testing should be highly organized and structured in a manner that allows for additional tests to easily be incorporated as new features are added. let's define a few terms to help facilitate a discussion on testing: · QA .the Research and Development team developing the application being tested · Build . The content in this section is based on years of experience "in the trenches" from people who have worked to build a productive and efficient automated test environment. In this section you'll learn about: · Basic testing terminology · Types of testing · Strategies for organizing and communicating your testing results · How to build a "smoke test" · Best practices for building durable tests that remain effective over time.3 Types of Testing Manual Testing Manual Testing is where a tester methodically exercises the features of a product or product area without the aid of test automation. Functional Testing Functional Testing focuses on interactions with an application's user interface (UI) via the mouse. leading to situations where consistently reproducing a bug can be very difficult. Through manual testing the tester can provide a wide variety of feedback about the application under test not limited to simply reproducing bugs.2 Terminology First.0 Release .a specific revision of the application under test that is submitted to QA · Application . The major weakness of manual testing is that it is time consuming. Copyright © 2009 AutomatedQA Corp. keyboard or other input device with particular attention to how the application visually responds to input. tedious and requires extended periods of very focused attention which can be very difficult to perform on a regular basis. Manual testing tends to be quite error prone. The single greatest strength of manual testing is that it is truly real-world testing. The goal of Functional Testing is to methodically cover all of the various UI features exposed by an application.36 TestComplete 7 Made Easy 3 3.

3. TestComplete provides the ability to leverage networked computers and virtual users to simultaneously submit HTTP transactions to a web application. The benefit of unit testing is that it tends to force application developers to write smaller more well defined routines with fewer dependencies allowing for more highly specific tests to be developed. Unit Testing requires internal knowledge of how an application performs and seeks to test portions (objects.The user interface or presentation of an application and it's data which is typically covered through Functional Testing. but not restricted to data. In many cases. HTTP Performance Testing HTTP Performance Testing is the simulation of real-world interactions with a web application from multiple machines. Regression Testing is extremely important and is the means of realizing the value of test automation.0 Release .Refers to the portion of the application responsible for moving data back and forth between the Client and the Data Tiers. Data Tier . The code that resides in this Tier can be tested from either the Client Tier via Functional testing or through Unit Testing on the code in the Middle Tier itself. we'll discuss the steps you should take to maximize the utility of your test automation efforts. Repeatedly executing tests over time allows you to verify the application is still performing in the manner in which it was intended. . Distributed Testing Distributed Testing is the act of farming different portions of a test out to separate machines for execution. applications have to be designed with Unit Testing in mind in order for this type of testing to be truly effective. Middle Tier and Data Tier.4 Before You Begin There are a few things you should know before diving into writing test automation using TestComplete or any test automation tool for that matter.Overview of Testing and TestComplete 37 Unit Testing Unit Testing is testing that focuses on smaller atomic portions of an application. Keep in mind that these are not strict rules as to which type of testing should be used but more illustrative how the different types of testing can be used. methods and function) of an application in isolation. Multi-Tier Explained In software development there are typically three Tiers which are used to describe various aspects of an application they are Client Tier. These are each defined as: Client . Regression Testing Regression Testing is the process of executing tests in a repeatable manner and comparing the latest results with previous test executions to ensure that the same outcome is achieved. In this section.2. Distributed Testing is useful for simulating real world interactions on a networked application such as a web site or web service and can exercise functionality designed to handle concurrent use of application resources including. Typically. Copyright © 2009 AutomatedQA Corp.The storage of an application's data which can be exercised by Functional Testing as well as Unit Testing Middle Tier .

Window( "ReBarWindow32". Quality Assurance and test automation specifically. "".Window("WorkerW". You should gain a thorough understanding of TestComplete's features before you embark on writing test automation to avoid a situation where you're weeks into test development only to discover a feature that could have saved you numerous hours or days. 1). For example.. 1) In TestComplete 7.Window("ComboBoxEx32". it's not a bad idea to start with a recorded script and massage it into what amounts to a handwritten test. 1). you should consider version control the next priority and work to get your test suites under version control. recorder making it easy to quickly create automated tests. Use a Source Control Repository TestComplete is a development tool and as such the projects. but not that kind of planning. In order to maintain consistency across your testing organization you should work towards creating a project template(s) that's pre-configured for your test environment. Creating solid test automation that can stand up over time and provide valuable ongoing feedback is a difficult task which leads a lot of people (read management) to think time and effort spent working on automation is wasted. If this is something you're already doing. recorded tests tend to be more brittle than hand written tests because they capture a single iteration at a given point in time and don't take into account unexpected events like an error dialog popping up. . Plan your testing. The planning we're referring to has to do with your choice of testing tool. create a Project Template that has the Tested Applications node with your application already added to it. tends to get a bad rap. scripts. TestComplete provides some facilities for producing log output though you'll want to be sure and iron out your strategy from the start. Also. etc. data. 1). That said.Window("Edit". There are Copyright © 2009 AutomatedQA Corp.Window( "ComboBox". "". if you're testing a Window 32-bit GUI application. skip ahead.IEFrame(0). If not. For example. For example. "". TestComplete is rich with features that make test automation easier although like any development tool it provides many different ways to solve the same problem. While a test recorder is a great tool. a new automatic NameMapping feature has been added to make this even easier. "". The down side of handwritten tests is they tend to take longer to develop though over the long run they'll likely require less maintenance because of the tendency to design the test more rigorously. Planning sounds like an obvious first task and although it's important to plan in terms of testing an applications features it's also important to plan with respect to the testing facilities available in TestComplete. TestComplete supports exporting log results to HTML which could be a good starting place. TestComplete has a powerful and indeed almost alluring. used in your tests should be kept under version control.Process("iexplore").2.38 TestComplete 7 Made Easy Communicating Test Results Now you might be thinking "huh? I haven't even started yet and I have to think about communicating my results?" The answer is a resounding YES! Unfortunately. 1). TestComplete. look closely at how you can utilize Aliases to avoid using long dotted object names like: Sys. Organizing your TestComplete projects TestComplete provides the ability to customize the Project Items that are included by default on a new project using Project Templates.0 Release . at least in the software world. The alternative is handwritten tests where you can methodically plan how the test will react in unexpected circumstances. To solve this problem you'll want to focus on getting your test results published quickly and consistently to prove that you're efforts are worth the investment. you may want to setup a web server where you can publish results in fact. ""..

the first test you should focus on is a "smoke test". a process called Continuous Integration or CI. Creating a Smoke Test Probably the most important test you'll write is your smoke test. In this section we'll discuss what a smoke test is and provide guidance as to how to construct the test in such a way as to maximize its effectiveness. It's unacceptable to have a smoke test that can't run consistently and without problems. In addition. By setting up a CI server you can not only alleviate your QA engineers from having to manually execute their tests but you'll quickly identify tests that are unable to consistently run to completion and may require closer scrutiny. many CI servers include a means of publishing test results providing for great visibility into the automation efforts. If you've never written a smoke test before. . 3. work to increase its coverage but remain focused on the quality of the test. Typically. focusing on breadth not depth · Require minimal setup/configuration of the application under test · Be setup to run against every build · Adapt over time as the application under test evolves · Serve as a model for new test automation If you take the time to organize your smoke test to cover these goals you will undoubtedly save time and resources over the long run.5 Your Most Important Test Arguably. In addition to Automated Build Studio there are Open Source CI servers such as CruiseControl. AutomatedQA has a product called Automated Build Studio which can automate your TestComplete tests and trigger them to execute when a new build is delivered to QA.Overview of Testing and TestComplete 39 lots of options including some excellent Open Source projects which are freely available like Subversion. Executing your Tests Regularly Once your smoke test is written and under version control the next step is to automate its execution. While it's beyond the scope of this document to discuss the specific merits of source control it's a subject that shouldn't be ignored.2.0 Release . Over time. The smoke test is crucial because of the time savings it can provide both R&D and QA. In the beginning simply get the smoke test to verify even a single piece of functionality consistently. Copyright © 2009 AutomatedQA Corp.as soon as a failure is detected in the smoke test should end and trigger a failure notification · Cover a broad range of functionality.a smoke test should not last for hours but minutes and test the most crucial functionality · Fail quickly . start small. A good smoke test should: · Run quickly . Your smoke test should serve as an model that embodies your "best practices" from which your QA team can draw from for their own tests. The main benefit of a CI server is to reduce the amount of time it takes to execute your test automation as well as ensure that it executes against every build. the goal of a smoke test is to verify that the latest build delivered to QA is either worth further consideration or DOA (dead on arrival). otherwise known as SVN. at least it should be.NET.

being executed consistently and the results are clearly communicated to the people who need them. Before diving in and unleashing the full power of TestComplete be sure to organize your communication strategy. . that statement is only true as long as your existing test automation is working. Copyright © 2009 AutomatedQA Corp. However. Also. the goal of test automation is to save time. money and improve quality. Test automation can relieve you of the task of manually testing existing functionality allowing you to focus attention on areas not already covered by automation.0 Release .6 Summary To best leverage your investment in test automation it's important to plan your overall testing strategy.2. Remember the Goal Ultimately. treat your test development like any other software development project and use the tools available to maintain the quality and integrity of your test code.40 TestComplete 7 Made Easy 3. Make communicating your results an important part of judging the success of your efforts.

Part IV TestComplete IDE .

.42 TestComplete 7 Made Easy 4 4.1 TestComplete IDE Objectives This section introduces the basic tools you need to work effectively with TestComplete. · Locate the Menus. Toolbars. 4. From the figures below.0 Release . you can see the File. Object Browser and Project explorer.2. Workspace areas. Script. View. Tools and Help menus.2 Menus and Toolbars TestComplete Menus The TestComplete menus are no different from many Integrated Development Environments menus. Copyright © 2009 AutomatedQA Corp. Edit. · Get familiar with the TestComplete Code Editor and all its features. In this section you will: · Get familiar with the TestComplete environment. · Gain a solid understanding of the Object Browser. · Gain the necessary knowledge of debugging in the TestComplete Editor.

formatting. . Saving files. recording.. add it by right clicking on the toolbar and choose customize. The great thing about the toolbar is that it is customizable.. So if you ever use a TestComplete functionality often and you don't see it on the toolbar. searching.TestComplete IDE 43 TestComplete Toolbar The TestComplete Toolbar is an easy way to get at TestComplete functionality or deeper menu items with only one click.0 Release .2. debugging. playing back. Once you drag a Copyright © 2009 AutomatedQA Corp. adding new units. Click on the Commands tab and drag any functionality you desire to anywhere on the toolbar. etc.

1 Panels and Workspaces Project Explorer The TestComplete IDE as you might expect consists of several pluggable windows that facilitate project management.3 4. the icon is persisted there permanently.2. object browsing.44 TestComplete 7 Made Easy command to the toolbar.0 Release . . Copyright © 2009 AutomatedQA Corp.3. main script and result logs workspaces. code management. 4. debugging.

0 Release .2. .TestComplete IDE 45 The Project Workspace consists of two main windows. The Project Explorer and the Code Explorer. Copyright © 2009 AutomatedQA Corp.

0 Release .46 TestComplete 7 Made Easy Copyright © 2009 AutomatedQA Corp. .2.

rename functions. delete functions. You Copyright © 2009 AutomatedQA Corp. is a different view into your code base that enables you to navigate easily between functions in large files. sort functions by name in the tree. 4. It is where all the brains behind the TestComplete muscle reside. If you ever missed a Project Item from the Wizard at startup. where you will be presented with all TestComplete Project plug-ins to add to the project.3. . The Code Explorer on the other hand.2 Object Browser The Object Browser is the most powerful part of TestComplete. etc.0 Release . you can always right click on a Project in the Project Explorer and choose Add New Item.TestComplete IDE 47 The Project Explorer will allow you to see all projects in a suite and all the specific Project Items that are part of a specific Project.2.. the engine monitors all running processes on your machine and extracts vital information about each process for display as you can see below.. When you click on the Object Browser Window in TestComplete.

2. Copyright © 2009 AutomatedQA Corp.3. from a testing perspective. CPU count. and other useful information. .1 Process Tree Pane The Process Tree Pane enables you to view all currently running processes on the machine and its toolbar on top allows you to filter the processes from running application to system processes to chosen testapps applications in your TestComplete project. The Object Browser can also examine your system as a hardware unit and report on the CPU.2. 4. operating system in use.48 TestComplete 7 Made Easy can filter the kind of processes you need to inspect or eliminate a category of processes by right-clicking on the Object Tree below on the left and filter processes.0 Release . amount of memory (RAM) on the machine.

2.0 Release . terminate. the popup menu appears with options to refresh the content of the tree.TestComplete IDE 49 By Right clicking anywhere in the Object Tree Pane. . filter. Copyright © 2009 AutomatedQA Corp. copy to editor. sort and other useful functionality that we will discuss later in this chapter.

invoke the 3rd menu option from the top called Object Properties.0 Release ..2. . Copyright © 2009 AutomatedQA Corp.3.50 TestComplete 7 Made Easy 4.. that will invoke the following dialog when you need to quickly dissect a window on the screen..2.2 Object Properties Pane From the Object Tree Pane.

2. View the Object Browser in TestComplete to determine that the process of Notepad has been detected by the Object Tree. Copyright © 2009 AutomatedQA Corp. . Object Tree Pane and Object Properties dialog to work with a Notepad window: 1. let's use the Object Browser. Open Notepad from the Windows directory or System32. depending of the version of Windows you are running.TestComplete IDE 51 As a Lab for this part of the chapter.0 Release .2.

. etc. Copyright © 2009 AutomatedQA Corp. To make sure that the main window of Notepad is the 3rd one underneath the process. right click on it and choose Highlight on the Screen. .52 TestComplete 7 Made Easy Notice that the process of Notepad is displaying three windows underneath the process and the Properties of the process itself are displayed on the right.0 Release . The other two windows (IME and MSCTFIME UI) are other non-visible windows in Notepad for language direction reasons like Hebrew and Arabic. 3..2. The main Notepad window is actually the 3rd one down.

.0 Release .2. all the other ones are READ ONLY and you will not be able to change their values in the Object Browser.TestComplete IDE 53 Note: The Notepad application is brought to the front and the main window starts flashing with a red rectangle around the main window several times. Copyright © 2009 AutomatedQA Corp. That means these properties are READ-WRITE as far as the Object Browser is concerned. Notice in the Properties window that the properties that you can change have a small grey circle on the left of them. 4.

This property is actually the title of the window.54 TestComplete 7 Made Easy 5. Now go back to the Notepad application and view the title area of the application. One of the properties of that main window in Notepad is called "WndCaption" and it has the gray circle next to it. That means it can be written to from the Object Browser. . Push the CTRL key and click inside of the edit area of the property. 7. Type "Welcome to TestComplete 7" and press [Enter].2.0 Release . 6. Copyright © 2009 AutomatedQA Corp.

Drag the Finder tool to the white area in Notepad until you see a red rectangle around the edit portion only. Copyright © 2009 AutomatedQA Corp. 9.2.TestComplete IDE 55 Don't worry.0 Release . 10. Now let's use the Finder tool to capture the Edit window in Notepad (The white area only with no Notepad title or menus). you did not change Notepad forever :) it is only for this session until it is shutdown and started up again. The Object Properties will automatically refresh and show all the properties TestComplete was able to see from the Window object in memory. . Invoke the Object Properties dialog from the popup menu of the Object Tree. 8.

developed or compiled as to what TestComplete will be able to see inside of it. you probably noticed that TestComplete recognized a lot of properties of the main Notepad window as well as the Edit window.1 Introduction From the previous sample with Notepad.3. Even the Methods tab had only methods pertaining to standard TestComplete functionality and actions. This brings up the topic of White Box Applications Vs.3. The button pointed to by number 2 above will allow you to highlight the object on the screen by flashing it several times.2. TestComplete will recognize objects and will go as deep as the application will allow it to. This is a very handy button when your application windows are numerous and have a deep hierarchy as is the case for Internet Explorer. . Copyright © 2009 AutomatedQA Corp.NET and Java application without any changes to the application just because of the nature of metadata generation of . So where are Notepad's methods.56 TestComplete 7 Made Easy The button pointed to by the number 1 above will allow you to highlight the window object in-place in the Object Tree Pane as part of the Object Browser. TestComplete will be able to automatically see deeply inside .3 Object Recognition 4. Black Box Applications. it is based on how the application was built.3. So these are always called White Box Applications. similar to step 3 above. you probably also noticed that the Fields and Events tab were blank.NET and Java application which are easy to reflect. Fields and events? Well.2. methods and events. On the other hand. 4. That means. properties.0 Release . Reflection is the ability to retrieve internal objects.2.

2.TestComplete IDE 57 And with the introduction of TestComplete 7. TC 7 enables these application by default.2 White-Box Applications While viewing the Object Browser. I used Visual Studio 2008 to generate a very simple C# based Windows application that adds two numbers together Copyright © 2009 AutomatedQA Corp. Delphi. In this sample. C and C++ application do not need to be compiled with a special header to making it a White Box tested application.3.2. you will notice sometimes that a TestComplete icon will show next to a specific process. That sign identifies the process as "OPEN" and means TestComplete can reflect its content and get as much Runtime Type Information as possible. .0 Release .3. 4.

Text) + Convert. if we had a function in the TCDotNetApp.exe called "Hello" that was never called from the User Interface. At this point.NET application so it started using the built in "WINFORMSOBJECT" identifier to make it easier to reach all .Text)). Note: TestComplete has many built in recognition objects for Delphi VCL objects.Text = (Convert.ToInt32(TxtNumberOne.ToString(). Notice that TestComplete automatically figured out that we are dealing with a .NET methods. EventArgs e) { TxtResult. Java Swing objects. Copyright © 2009 AutomatedQA Corp. the executable is available through the book download as "TCDotNetApp. fields. We would be able to call it directly from the script and it will be visible to TestComplete via reflection.exe".2. } In case you don't have Visual Studio.ToInt32(TxtNumberTwo. events and properties associated with the application.0 Release . it will still show up in the Methods tab.58 TestComplete 7 Made Easy The only line of code in this example is: private void btnAddition_Click(object sender. .

4.TestComplete IDE 59 XAML WPF objects and others. For example. methods and events available for that object. .3. Instead of having prior knowledge of the objects you need to deal with in TestComplete or have access to the Help files. when you need to know the count and type of a parameter that TestComplete recognizes. One of the first features you will discover and love in the TestComplete Editor is the Code Completion feature. That is possible using the handy keyboard shortcut CTRLSPACE.2.. you can always open a parenthesis and key in CTRL-SHIFT-SPACE to bring up the Parameter completion window: Copyright © 2009 AutomatedQA Corp. it is simple enough to let TestComplete do the job for you by entering the name of an object and placing a "..3.0 Release . Another great feature of the TestComplete Editor is the Parameter Completion feature.3. Sometimes you even have the need to invoke the Code Completion window in the middle of a statement. I am not sure how we used to write code before this feature was introduced in major development tools and in TestComplete. That will invoke the Code Completion window with all properties.1 Editor Code Completion The Code Editor in TestComplete is easy to use and productive to get the job done.3 4." period after the object.

60 TestComplete 7 Made Easy 4. press CTRL Copyright © 2009 AutomatedQA Corp. their unit names and their line numbers.2 Bookmarks Another great feature of the editor in TestComplete is the ability to place bookmarks in script units opened in the IDE and be able to jump between them by a simple keystroke.0 Release .2. In the figure above. the Bookmarks window at the bottom of the editor will list all set bookmarks with their numbers. please notice that the bookmarks are set on lines 5. NOTE: The project in the screenshot below is for illustration purposes only.15 and 18 (see the yellow glyph in the gutter).and a number between 1 and 9. To jump to a specific bookmark at any time. Also.SHIFT . You can set a bookmark by having the cursor on that line and pressing CTRL .3. to work with Editor Bookmarks you can use any of the courseware projects or create a new project.3. .

you have the choice to change the Text specifications. Copyright © 2009 AutomatedQA Corp. background colors and margin. 4.0 Release .3 Editor Options From Tools | Options. . gutter styles and capacity and also whether you want to show line numbers or not.TestComplete IDE 61 .0 to 9 (without the SHIFT).2. you can get to the Editor options under Panels | Code Editor: Under Display. To delete a bookmark.0 to 9 again while the cursor is on the bookmark.3. delete from the bookmark window or press CTRLSHIFT. Another very useful feature of the editor in TestComplete is the ability to set Code Templates.3.

J. The script itself can be anything that you expect to use a lot in your testing. The pipes indicates the position of the cursor in the code after the template has been inserted. .2. The following code template helper will appear: Copyright © 2009 AutomatedQA Corp. Now lets go back to the editor and try to enter this template: 1.62 TestComplete 7 Made Easy Every scripting language has it own templates.0 Release . Notice also the little pipe "|" sign inside the brackets. Choose an empty area between two functions and press CTRL . Above you will see that I added a new Template called TCTraining that contains a function name "test" with a comment in it.

0 Release .3.3.TestComplete IDE 63 2.2. Choose the TCTraining Template from the list and press Enter. Copyright © 2009 AutomatedQA Corp. . flow problems and also to evaluate the values of local and global variables. 4.3. The code is inserted in the script unit and the cursor is blinking right before the comment starts.4.3.4 Debugging 4.1 Breakpoints The Debugger capabilities in the TestComplete's Editor are very helpful in finding script errors.

3. · Include a description to explain the goal behind using the breakpoint. The figure below shows the Call Stack at a break in execution. knowing that it will fail some time after 900 times. That is better than deleting them and reentering them all over based on different debug sessions.2. the Call Stack window will show the order of execution for the calling functions to get to that point of execution. so the problem you are trying to figure out Copyright © 2009 AutomatedQA Corp. · View the Location of the unit name it resides in and also the line number of where it resides. When the pass count is not known but a condition has to be met. In the Breakpoints window you can: · Enable or disable a specific breakpoint. Usually that is good information for pinpointing the offending procedure. . Unfortunately. During a break in execution. You can set breakpoints in your editor by clicking in the gutter next to the line you want to set a breakpoint on or by pressing F5 while the cursor is on that line. in many cases "X" does not mark the spot like in an Indiana Jones' movie.g: x > 100). the Condition property can be set (e.0 Release .2 Call Stack The Call Stack window is very helpful when your scripts get called one from the other in a long chain of execution. you have two powerful features in the breakpoints window which are Pass Count and Condition.4. · Finally. 4. it would be wise to place a Pass Count of 900 on the breakpoint instead of having to step over the breakpoint 900 times.64 TestComplete 7 Made Easy The Breakpoints window in TestComplete is very easy to use.3. If you are debugging a "For Loop" that goes on for 1000 iterations.

4.3.3 Locals The Locals window is an easy and fast way to monitor the value of local variable inside of a specific function. and assigned specific values to both. you only need to open the Locals window and they will be there as long as you are breaking inside of the function that contains them. These are tougher bugs to figure out. 4. we created 2 local variables.2. So how do you view values of variables that are not local to a function? That is the functionality of the Watch List. . "myString" and "myNumber". Copyright © 2009 AutomatedQA Corp. To view their values.0 Release . Like in the figure below.TestComplete IDE 65 has already manifested itself way before the break in execution occurred.3.

66

TestComplete 7 Made Easy

4.3.3.4.4 Watch List

Notice in the screenshot below that the Global variable "myGlobal" did not show up in the locals window. This is correct, as the myGlobal variable is not a local of that function.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

TestComplete IDE

67

To evaluate the myGlobal variable, go to the Watch List window and add a new item by right-clicking in the window.

The output in the Watch List window will allow you to monitor the value of that variable during the life of the execution session.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

68

TestComplete 7 Made Easy

You can also use the Evaluate command available from the debug menu item in the editor:

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

TestComplete IDE

69

The Evaluate dialog displays the current value of the expression.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

70

TestComplete 7 Made Easy

4.3.4
4.3.4.1

Visualizer
Objectives In this section we'll take a look at TestComplete's Visualizers feature and you will learn how to: · Enable Visualizers · Work with Visualizer Gutter icons The Visualizer can be particularly useful when providing feedback to people unfamiliar with a particular test script. The recorded screenshots function as a storyboard for the script allowing the person reviewing the results to more quickly understand what actions caused the problem.

4.3.4.2

Enabling the Visualizer The Visualizer records screenshots during recording or script playback allowing you to see exactly where the action took place. By default TestComplete's Visualizer feature is turned off and requires that you manually enable it in order to capture Visualizer data. To enable the Visualizer select Tools | Options... and select Engines | Visualizer:

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

TestComplete IDE

71

Visualizer Options

You can enable the Visualizer before recording and/or before playback. You and also specify what part of the screen will be captured using the Capture Style.

4.3.4.3

Working with Visualizer Images Once you have enabled the Visualizer for recording and/or playback you will see cues in the Script Editor gutter indicating images have been captured. Notice in the picture below lines 18, 20 and 23-25 all have a image icon displayed in the editor gutter:

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

72 TestComplete 7 Made Easy Double clicking these image icons will display the Visualizer Images dialog allowing you to peruse the captured images.. .2. menu item was clicked. Visualizer Im ages dialog Copyright © 2009 AutomatedQA Corp. The dialog displayed below appeared after double clicking the Visualizer icon in the gutter on line 20 from the script above where you can clearly see the Orders | New Order.0 Release ..

Workspace areas.0 Release .TestComplete IDE 73 4. · Located the Menus. · Gained the necessary knowledge for debugging in the TestComplete Editor.2. · Gained a good understanding of the Object Browser.4 Summary In this chapter: · You got a tour of the TestComplete environment. Toolbars. Copyright © 2009 AutomatedQA Corp. · Got familiar with the TestComplete Code Editor and all its features. . Object Browser and Project explorer.

Part V Projects and Suites .

. In this section you'll learn about: · The difference between a Project and Project Suite · Understand the components of a Project · Learn to use the Project Wizard · Create a simple test 5. the scripting language to use and the location to save the project. If you would like to use the "classic" Create New Project dialog. To create a new project select File | New | Project.0 Release .1 Projects and Suites Objectives This section looks at the structure of a TestComplete project and the parts that make up the various testing functionality included in a project. A Project Suite is a container of projects providing a mechanism to logically group related projects.Projects and Suites 75 5 5.. feel free to click on the "Classic" button Copyright © 2009 AutomatedQA Corp. .2. and you will be presented with the Create New Project dialog: This is a much simplified dialog than previous versions of TestComplete that asks only for the Project Name.2 Project Anatomy In TestComplete a Project is a container of test scripts and other Project Items used by the tests that make up the project.

useful for a wide variety of test scenarios · Object Driven Testing .template that includes all of TestComplete's available Project Items Once you click OK on the Create New Project dialog you will be presented with the Project Wizard which allows you to further customize your New Project. JUnit.for managing test execution of projects on different computers · HTTP Load Testing .2.0 Release .for running MSTest. . Copyright © 2009 AutomatedQA Corp. The templates are: · General Purpose Test Project .76 TestComplete 7 Made Easy and you will be presented with the following dialog: The "Classic" Create New Project dialog presents you with a number of pre-configured Project Templates that are geared towards specific types of testing.for load testing web server applications · [All Items] . DUnit or TestComplete unit tests · Distributed Testing . NUnit.for working with custom data structures · Unit Testing . After creating a new project you can view all of its Project Items and sub items from the Project Explorer. For more details refer to the following section on the New Project Wizard.

Projects function as containers for different pieces of functionality related to testing and are organized on disk in a similar file/folder structure. .A Project Item Element Structure of Projects in TestComplete In TestComplete.Projects and Suites 77 The various parts of a project are as follows: · MyProjectSuite .A Project Suite · MyProject . In fact.0 Release . removing a node from Project Explorer only removes it from the logical view presented by TestComplete and does not actually delete the item from disk which means you can easily add removed items back to a project.A Project Item · Stores · Tested Apps · Unit1 .2. Here is the above project viewed from within Windows Explorer: Copyright © 2009 AutomatedQA Corp.A Project · Name Mapping · Script .

· Folders: Provides a means of organizing Project Items and Project Item Elements within a Project.. Adding them at the time a project is created is a matter of convenience. · Project Item Elements: The child nodes that represent testing functionality of the Project Item or serve to organize its contents. When a project is initially created you have the opportunity to specify which Project Items you want included. .2. TestComplete includes a large collection of Project Items covering a wide variety of test functionality. You can add and remove Project Items at any point. Both Project Suites and Projects provide a logical view of the files and folders that make up the project.78 TestComplete 7 Made Easy Projects Projects can contain the following: · Project Items: Provide support for a specific type of testing. Project Items Project Items make up the specific types of testing functionality or assist in performing various test operations. When removing nodes from the Project Explorer you are only removing them from this logical view. You can easily add and remove Project Items using the right-click menu on the Project node Copyright © 2009 AutomatedQA Corp.0 Release . The actual files and folders are not deleted from disk and may be added back to the project using the right-click context menu and selecting Add | Existing Item..

Projects and Suites 79 of the Project Explorer.3 New Project Wizard The New Project Wizard is provided as a convenience allowing you to configure a new project with a default set of testing functionality. It's not crucial to know up front all of the necessary Project Items that your project will require as Project Items can be added or removed directly from the Project Explorer after the project has been created. . Copyright © 2009 AutomatedQA Corp.0 Release .2. 5.

Stores Copyright © 2009 AutomatedQA Corp.xml making it easy to share templates with your entire team.Setting up a Custom Template If you're testing a Windows Application you may want to setup a Project Template that's geared towards that type of testing. Select File | New | New Project.. accepting the defaults on this dialog will be the preferred choice until you're familiar enough with the available Project Items and can identify the ones you use most frequently at which point you can create a Project Template. Project templates are located in <TestComplete>\Bin\ProjectTemplates. button to create a new Project Template that will be available on the Create New Project dialog. The following walkthrough demonstrates how to create a custom Project Template you may find useful for testing Windows applications: 1..2. Best Practice .Name Mapping . In any testing organization it's important to establish standards like this to help maintain consistency across your testing organization. 2. To define a new template select the Project Items you use most frequently and click the Save As. On the Create New Project dialog from the list of Templates select the [All Items] template 3.. .80 TestComplete 7 Made Easy Project Templates Initially. Click the Unselect All button at the bottom of the Project Items checkbox 4.0 Release . Check the following Project Items: ..

Click the Finish button Deleting a Project Template TestComplete 7 does not have built-in UI for editing or deleting Project Templates. In the left hand column on the dialog click Tested Applications 6.2.) button to select the application 9.Tested Applications 5...0 Release . you can manually edit <TestComplete>\Bin\ProjectTemplates. Click on Classic Copyright © 2009 AutomatedQA Corp. At the bottom of the Items list click the Add button to add a specific Windows application to test against 7.. In the left hand column of the dialog click Select Project Items 11.4 Hands on Lab: Create a Simple Test Creating a Simple Project 1. Click the Save As. 5. or use the ellipsis (. However.xml using a plain text editor such as Windows Notepad to delete or modify an existing template.. Select File | New | New Project. On the Save Template dialog enter a Template Name and Description and click OK to create a new project template that you can reuse 13. type the complete filename including the path to the Windows application you wish to test. On the Create New Item dialog fill in the name of your application and click Next 8. .. Click the Finish button 10.Projects and Suites 81 .. button 12. In the Tested application edit box.

2. .5 Summary In this chapter we covered the structure of a TestComplete project and the parts that make up the various testing functionality included in a project. Select General Purpose Test Project and click the OK button 3. accepting the defaults 5.82 TestComplete 7 Made Easy 2. You should be familiar with how to construct a Project Template for use across your organization for greater consistency and ease of use when creating new test projects. On the New Project Wizard click the Finish button.0 Release . Copyright © 2009 AutomatedQA Corp.

Part VI Project Items .

Necessary for the creation of a load on a web server using TestComplete. For example you could use the Microsoft ADO Data Control to work with databases. Copyright © 2009 AutomatedQA Corp. . · Keyword Testing .A virtual folder for holding low-level (screen coordinate based tests) procedures.84 TestComplete 7 Made Easy 6 6. This item is required.This project item is used to hook to TestComplete events (and those of other application. · Low-Level Procedure Collection . · Events . · HTTP Load Testing .0 Release . such as ActiveX controls).1 Project Items Objectives This section provides an overview of all project item types with additional detail on the Tested Application.Allows for the visual construction of scripting blocks to help build logic without being familiar with code syntax.This project item allows you to load an ActiveX object in TestComplete's memory space and use that object in your tests. 6. · ActiveX .2 Project Items The Project Wizard Select Project Items tab allows you to select which project items are included in the project.2.

this application will be run if TestedApps.Show the icon associated with the tested application · Launch . etc).Object Driven Testing used to add pseudo class structure to script code.Is the name that TestComplete uses to refer to the tested application (must be a name that the scripting language can handle). · Stores . · Count . such a progress dialog. · Tested Application .If checked. THIS ITEM IS REQUIRED. · Parameters .Project Items 85 · Manual Test . · Run Mode . · Web Services .2.Used to map the name of an object to a shorter name (aliasing).Holds information for managing the Application(s) under test.RunAll command is used (either from script or context menu).Launches the application under the same user account as TestComplete.How the application is launched. · Network Suite .0 Release .A virtual folder for holding manual tests. · File Path . File Path is the relative path to the file name from the TestComplete project. · Script .Is the name of the application on the disk. Copyright © 2009 AutomatedQA Corp.2. If the application is already running TestComplete will post a warning message in the Test Log.A virtual folder for holding User Forms (Forms presented to the user during the test run.This is the number of instances of the application that TestComplete will launch. methods and type of web services (Information from the WSDL file).A virtual folder for holding Unit Tests. .Holds collections of checkpoints used in a project · Unit Testing .A virtual folder for holding connection.Holds a collection of script units. · Name . Run Mode · Simple .By default. · File Name . · ODT . Parameters can be passed in Simple mode. · User Forms . · Name Mapping .Used in distributed testing.1 Tested Applications The screenshot below shows the configuration of a tested applications project item: · Icon . 6.Allows parameters to be set using the ellipses button.

Launches the application inside of AQTime using the profile (or AQTime project) specified in the parameters dialog.Launches the application under the same user account as TestComplete.Launches the application under the user account specified by the parameters dialog.86 TestComplete 7 Made Easy · RunAs .0 Release . The stack trace of any exception that occurs in the application while the test(s) are being run will be recorded in the TestLog. Copyright © 2009 AutomatedQA Corp. · Debug .2. For example code coverage profiling could be used to see how much of the code is being tested by your automated tests. This option requires debug information in the application under test. then TestComplete attaches to the application as a "debugger". · Profile . .

0 Release .Project Items 87 6. Copyright © 2009 AutomatedQA Corp. .3 Summary In this section we had a brief overview of the project items of TestComplete.2. We also looked at the Tested Application project item in more detail.

Part VII Test Log .

. warning messages and events as well as entire files and images. 7.2 Test Log Logs are used to persist feedback from your tests including errors. · Learn how to email the test log. The context menu for the Log Tree contains menu items to handle the log output including Export to IE. Logs are stored in a directory as XML files.2.Test Log 89 7 7. · How to reduce test log size using LockEvents. We will learn how to email the test log and also how to reduce the size of the test log. Log Tree This area will have a node for each Test Item level used to run the test. The project suite is the top (root) node and each project is represented by the child of the project suite. for example. In this section you will: · Learn about the basic Test (Results) Log. a project suite was run. The statuses of child items in the tree bubble up to the parent items. · How to view the Test Log in Internet Explorer. Copyright © 2009 AutomatedQA Corp. In the screenshot above you can see that errors flagged in child level items (the red X indicates the error status) have bubbled up to the project suite node. Send Email and the ability to view closed Log Panels. In the image above.0 Release .1 Test Log Objective This section discusses the test log and the types of messages available in TestComplete.

. Log.e. Copyright © 2009 AutomatedQA Corp. To preview what this file will look like.Can come from TestComplete or from the script code (Log. will copy the file into the directory holding the log XML file and creates a hyperlink to the file.Warning).3 Emailing Result Sending the result via email can be done either by script code (see help file for examples) or after the test run by selecting Send via Email. View Results in IE also shows how TestExecute will display Test Results after a test run. · File .Can come from TestComplete or from the script code (Log. TestComplete generates an event for every mouse-click or keyboard entry in the test. AppendFolder. Log. Log.Event). from the Log Tree context menu.. will not cause the test to fail.Message). not necessary a failure for the test but could be an indicator for why a test failed.Usually comes from script code (Log. select View Results in IE from the context menu. the top of the stack). . Selecting Send via Email.There are two types of File log items.. does not cause the test to fail.Error).2.Picture) but TestComplete can generate as well (Region Checkpoints). · Image .. 7. this indicates a failure for the test.. · Events . All messages by default go into the last pushed log folder (i. · Warning .PushLogFolder. The test log area may have a hierarchical structure via creating and pushing log folders onto the log (Log. · Error .Can come from TestComplete or from the script code (Log. creates an email with a multi-part hypertext file attachment.CreateFolder/Log.Link just creates a hyperlink to the file without copying the file.File.90 TestComplete 7 Made Easy Test Log This area contains messages coming from both TestComplete and the script code.Usually comes from TestComplete but can come from the script as well (Log.PopLogFolder). There are six different types of messages: · Message .0 Release . Log.

.4 LockEvents With any long running test. the test result log will be filled with hundreds if not thousands of events.0 Release .2. Copyright © 2009 AutomatedQA Corp.Test Log 91 7.

By default the last 20 events are logged. TestComplete can eliminate events unless an error occurs. .92 TestComplete 7 Made Easy Most of the time.LockEvents to the script code. the tester is not interested in events unless there is a problem in the test run. but this can be changed by adding a parameter to the Log. Copyright © 2009 AutomatedQA Corp.5 Summary In this section we learned about the test log and the different type of messages available in TestComplete.LockEvents command. 7. no events will be placed into the test log unless an error occurs.2. By adding Log.0 Release . We learned how to email the test log and also how to reduce the size of the test log.

Part VIII Name Mapping .

94 TestComplete 7 Made Easy 8 8. · Aliases and how they are different from Name Mapping · How TestComplete uses Alias and Name Mapping. Container2 and button1 to useful names like MyPanel.0 Release . For example: Sys. Panel2.exe applications that comes as an example with TestComplete 7.Container1.Container2.Process("Hello").Panel2. If you create the Alias "btnSubmit". 8.myTabs. myTabs. Container1. In this section you will learn about: · Named Mapping. you only need to type: Aliases. myInsidePanel. . The issue here is that you still need to type: NameMappings.Sys.2 Map to Object TestComplete 7 provides automatic Name Mapping and Aliases to tame extremely long object identifiers that have somewhat unclear default names. myPages and btnSubmit. Named Mappings allow you to rename Panel1.myInsidePanel.btnSubmit TestComplete 7 creates an Alias to represent this long string.btnSubmit Consider the Orders.2. its long and awkward not to mention we have no clue about the purpose or identity of "Container1".Panel1.Process("Hello").myPages.1 Name Mapping Objectives This section introduces Name Mapping and Aliases used to handle long object identifiers and to provide identifiers with meaningful names.button1 Clearly there are numerous issues with this identifier.MyPanel. "Container2" or "button1". located under Vista in "C:\Users\Public\Documents\TestComplete 7 Samples\Open Apps\OrdersDemo\C#\bin\Debug": Copyright © 2009 AutomatedQA Corp.

OrdersView.MainForm.Window ("SysHeader32". "". the automatic NameMapping feature takes place and records the mapping as "NameMapping.2. 1)" but in TestComplete 7. Copyright © 2009 AutomatedQA Corp.SysHeader32" which makes it much easier to understand and work with in scripts.Process("Orders").0 Release .Orders.Name Mapping 95 For Example.WinFormsObject("MainForm").WinFormsObject("OrdersView"). TestComplete already sees the header as "Sys. . if I want to have access to the header control in the table. during recording.

OrdersView. we can access the Header Control in 3 different ways based on the example above:  Sys. with that said. but the Aliases section can make the line of script much smaller by creating a specific Alias to a specific control that can be referred to anytime directly in the script.96 TestComplete 7 Made Easy The main difference between the NameMapping section and the Aliases section is the fact that the Name Mapping has to respect the parenthood of the hierarchy of the controls on the form.SysHeader32  Aliases. So.Orders.Window ("SysHeader32".WinFormsObject("OrdersView"). 1)  NameMapping.SysHeader32 But we can also drag the SysHeader32 from the NameMapping Section to the Aliases Section to make it at the same level as "Sys" like so: Copyright © 2009 AutomatedQA Corp.Orders.Process("Orders").OrdersView.MainForm.WinFormsObject("MainForm"). "".2. .MainForm.0 Release .

Let's say now you need to manually add the Toolbar to your Name Mapping Project Item: From the Object Browser tab.2.Name Mapping 97 That would allow us to access the Header in a fourth way as: Aliases. right click on the Toolbar window item and choose "Map the Object Name" Copyright © 2009 AutomatedQA Corp. .0 Release . Aliases allow you to ignore on-screen objects that were used for design but are not necessary to the test automation process.SysHeader32 In this way.

Of course. . By moving properties from the "Available" list to the "selected" list. the more properties you select the more unique the control would be. give it a description. if you wish. and mainly select the properties that would make the component unique on the form.2.98 TestComplete 7 Made Easy The Object Name Mapping Window appear that allow you to specify a new name for the Toolbar. Copyright © 2009 AutomatedQA Corp. how does TestComplete know how to differentiate between them at runtime when the script is run? That is why it is very important that you differentiate between your instances of controls or components with the least amount of properties (for speed) to make the call in the script not ambiguous.0 Release . it make TestComplete identify that control on the form by these attributes. The reason that is important is the fact of what happens if there are TWO controls at the same ownership level with the same selected properties that are equal to each other.

objects being referred to can be highlighted on the screen. .2. this is done by pressing the Highlight button.Name Mapping 99 8. Copyright © 2009 AutomatedQA Corp.3 Highlight Objects During mapping or after the fact.0 Release . In the Name Mapping dialog.

. highlighting is done by selecting Highlight on Screen from the context menu (right-clicking).2. Copyright © 2009 AutomatedQA Corp.100 TestComplete 7 Made Easy In the NameMapping project item editor.0 Release .

Highlights the currently selected object on the screen if possible. · Template Name .which template that TestComplete used to define the Selected Properties initially.0 Release . · Available Properties . Copyright © 2009 AutomatedQA Corp.Name Mapping 101 8. this button allows you to choose which template to use.additional properties that can be use to help refine the name mapping.Add the selected object to the Mapped Objects only. · Highlight .4 Mapping Dialog The parts of the Mapping dialog are listed below: · Mapped Name . · Skip .2.Add the selected object to both the Mapped Objects and the Aliases sections of the NameMapping project item.short note about the object · Selected Properties .if the on screen object matches one than one possible template. · Templates .the properties that are used to define this on screen object for name mapping.lets you define the name for an on screen object · Description .Allows you to add/edit Templates. . · Select . · OK .

The difference between Aliases and Name Mapping was explained.Cancel the mapping at this point (all items mapped before will still be mapped). If the object is not available in the Object Browser. 8. If the Alias object is available in the Object Browser. In manual coding you can use the Aliases as well. If that does not work.5 Aliases in Scripts If you are recording a script and have the NameMapping project item in the current project. TestComplete will first try to use the Aliases project item in the recording.2.102 TestComplete 7 Made Easy · Cancel .0 Release . And we learned how to map an object from the screen. This can be changed in the Options dialog (Tools | Options| Engines | Name Mapping) by selecting the Store CodeCompletion Information.Brings up the help on this dialog. · Help . 8.6 Summary We learned about what name mapping is and what it is used for. TestComplete will present a smaller subset of methods and properties. Copyright © 2009 AutomatedQA Corp. it will use the NameMapping project item. This does increase the size of the NameMapping project item file but allows you to code without having the tested application open. . then TestComplete will present all the properties and methods for that object.

Part IX Unit Testing .

the types of unit test frameworks supported by TestComplete and provides an example of using an NUnit unit test. The information can be entered in the Options Dialog (Tool | Options from the main menu).pas file. From the Options Dialog select Engines | Unit Testing. require that the test application be compiled as open and include the tcDUnitSupport. comes with Visual Studio 2008 and Visual Studio 2005 Team Edition. · JUnit .104 TestComplete 7 Made Easy 9 9. · NUnit .0 Release . Copyright © 2009 AutomatedQA Corp. · Provides an easy way for Quality Assurance to run unit tests (in addition to Developers running unit tests).A unit test frame work that allows unit testing of any open application. 9. · MSTest .An open-source unit test framework based on JUnit. · Can make it possible to run unit tests as part of the build process. In this section you will: · Learn about the types of unit test framework supported by TestComplete.NET applications.NET applications. · TCUnitTest . TestComplete supports five different types of Unit Testing: · DUnit .2.1 Unit Testing Objectives This section discusses unit testing.A unit test framework designed by Microsoft for unit testing . .A unit test framework for Delphi Applications. used for unit testing .2 Supported Unit Testing Types Running unit tests within TestComplete has several advantages: · Management gets a single report that includes both unit and automated tests.A de-facto standard unit test framework for Java Applications. Some of the unit test frameworks require that TestComplete know where the test runner application is located on the test machine. · See an example of using a Unit Test.

NET unit testing framework (available at http://www. 2. When it is installed.0 Release . Add a NUnit Project Item under the Unit Testing Project Item. 1. Copyright © 2009 AutomatedQA Corp. Add a Unit Testing Project Item to your project.org). . it includes a sample unit test assembly.Unit Testing 105 9.3 NUnit Example NUnit is a popular .nunit.2.

Click the ellipses button for the Assembly file name.0 Release . This will open the NUnit editor in TestComplete. Push the OK button. 4. Copyright © 2009 AutomatedQA Corp. . Right-Click the NUnit1 Project Item and run the test.2. 5. Add the Assembly that holds the NUnit tests.106 TestComplete 7 Made Easy 3.

. Copyright © 2009 AutomatedQA Corp.2.0 Release .Unit Testing 107 The screenshots below show sample output and logging for the test run.

Create a new project 2. Copyright © 2009 AutomatedQA Corp. . Add the "TestedApps" Project Item.) next to the process.4 Hands on Lab: Running a Unit Test 1..108 TestComplete 7 Made Easy 9. Run the Application (Right-Click on the "UnitTestingDemo" Project Item). Click the ellipsis button (. 7. Add a "Unit Testing" Project Item 6. 3.0 Release .. Add a "TCUnitTest" Project Item to the "Unit Testing" Project Item.2. Add the "UnitTestingDemo" application to the project from the directory "<TestComplete Install Dir>\Samples\Unit Testing\C#\bin\" 4. 5.

12. Select the "UnitTestingDemo" Process.0 Release . Click Run on the "TCUnitTest1" Project Item. Uncheck the "ShowNum" Method (this method has a UI which we do not want to handle in a unit test). 9. . 11.Unit Testing 109 8. Select the Mode of "Run selected tests only". Copyright © 2009 AutomatedQA Corp. 10. Click the Load button.2.

Copyright © 2009 AutomatedQA Corp.0 Release .2.110 TestComplete 7 Made Easy Most of the work for Test Cases in the Unit Test is done by the developer in the Application. 9. .5 Summary We learned about the types of unit test frameworks supported by TestComplete and how to use an NUnit unit test.

Part X Manual Testing .

. On the Project Wizard dialog click the Unselect All button then under Project Items check Manual Test and Tested Applications items Copyright © 2009 AutomatedQA Corp.0 Release . TestComplete Manual Tests allow the person performing the test to indicate whether or not the test passed or failed and provide additional feedback in the event of a failure.2. which will display the Create New Project dialog 2.112 TestComplete 7 Made Easy 10 10.. how to construct a simple manual test using one of the provided sample applications and how to interact with manual tests from scripts.2 Setting up a Manual Test Project A Manual Test in TestComplete is a test that is performed by an individual who is directed by instructions presented on screen. Creating a New Manual Test There is no default template for creating a Manual Test so we'll walk through setting up a new project for Manual Testing: 1. Select General Purpose Test Project and click OK 3. From the main menu select File | New | New Project. . In this section you'll learn: · What a Manual Test is · How to setup a Manual Test Project · How to create a Manual Test · How to use script within a Manual Test 10.1 Manual Testing Objectives This section discusses TestComplete's Manual Testing features.

Creating a Manual Testing Project 1. 10.0 Release . add steps to the manual test and how to run the manual test. set up a manual test. .Manual Testing 113 You now have a test that's setup for Manual Testing. Create a Project in TestComplete (with a new Project Suite) Copyright © 2009 AutomatedQA Corp.2.3 Hands on Lab: Create a Manual Test The step-by-step walk-through below demonstrates how to create a manual testing project.

114 TestComplete 7 Made Easy 2.2.0 Release . Select General-Purpose Test Project Template and click OK 3. On the Project Wizard dialog click Unselect All and then check Manual Test and Tested Application Copyright © 2009 AutomatedQA Corp. .

Double click on ManualTest1 to open the editor in the Workspace Copyright © 2009 AutomatedQA Corp.exe. Right click on TestedApps and select Add | New Item.2.0 Release . 1. Click Finish Setting up a Manual Test Here we'll walk through setting up a Manual Test using a sample application provided with TestComplete called Orders... Select Orders. 2.exe (which is a sample application included with TestComplete) 3.Manual Testing 115 4. .

.. Change Test caption to "Manual Test" and Test description to "Hands on Lab" 5. Under Test instructions type "Orders application must be running to complete this test" 6.0 Release .116 TestComplete 7 Made Easy 4. Under Test Steps right-click and select Preview Step Dialog. . (click Yes on the prompt to save the dialog) Copyright © 2009 AutomatedQA Corp.2.

. Under Test Steps click the Add Step 2.0 Release . Add the directions for opening a table to the Step Instructions button Copyright © 2009 AutomatedQA Corp. Click Cancel to close the dialog Adding Steps to a Manual Test 1.2.Manual Testing 117 7. In the Step caption edit box type "open" 3.

2..0 Release . Enter 2 in the Quantity Field c.. Add another step using the Add Step button and set the caption to "Add Order and Verify Quantity" 5. Verify that the Total Field equals 200 Copyright © 2009 AutomatedQA Corp. from the main menu b. .118 TestComplete 7 Made Easy 4. Enter the following Step Instructions: a. Select Order | New Order.

Click Fail 4. Click Begin Test 3. 1.0 Release . Click Continue At this point. Enter "Unable to find table" in the comment field 5.2. you should see the following test log: Copyright © 2009 AutomatedQA Corp. Click Success 8. Click Try Again 6. In the Project Explorer right click ManualTest1 and select Run ManualTest1 2.Manual Testing 119 Running a Manual Test In this section we'll walk through running a manual test and logging mock failures along the way. . Click Fail on the next step 9. Follow the rest of the step's instructions 7.

Note: Once the list appears you can begin typing to select the item from the list.exe sample application to the TestedApps Project Item. 3. VBScript is used in this example. Under the Scripts node in the Project Explorer double click Unit1 to open the code editor. Copyright © 2009 AutomatedQA Corp. Press Ctrl-Space to display the Code Completion window 6. . Select TestedApps from the list.4 Hands on Lab: Scripting and Manual Testing In this section we'll illustrate using Scripts with manual tests and cover how to hook Manual test events. NOTE: Your code will differ if you're using a scripting language other than VBScript though the basic concepts still apply.120 TestComplete 7 Made Easy 10. Add the Orders. Using Manual Tests from Script Code 1. Create a new TestComplete project. 2. In the Main routine.2.0 Release . add a blank line under the "Enter Code Here" comment 5. 4.

Manual Testing 121 7. Type a period "." to invoke the Code Complete again and select Orders 8. Select TestedApps 16. Press Return to add a new line below ManualTest1.Run() 10.Start 14. ." and select TerminateAll Copyright © 2009 AutomatedQA Corp.0 Release . Type "." and select Start 13. Press Return to add a new blank line below TestedApps. Type another period and select Run 9.Orders. Press Ctrl-Space to display the Code Completion window 11.2. With the cursor at the end of TestedApps type a period ". Press Ctrl-Space to display the Code Completion window 15. Select ManualTest1 12.

1. This example will build upon the Manual Test created in the previous step. . With the previous project still open expand the Events node in the Project Explorer 2.0 Release . Double click the GeneralEvents node 3.122 TestComplete 7 Made Easy Script Interactions with Manual Tests In this example. we'll illustrate using Events and Script to interact with a user during a Manual Test.2. In the Workspace under Available Events expand the Manual Testing Events node Copyright © 2009 AutomatedQA Corp.

Click OK on the New Routine dialog to add a new function to the Unit1 test script 8. Run the Project and click the Begin Test button. Double click the OnBeforeStep event to add the event to your test 5.2. In your Unit1 script file add a new blank line below the function declaration and type 'BuiltIn. Notice the ShowMessage dialog appears: Copyright © 2009 AutomatedQA Corp. Click on the OnBeforeStep item then click the New button 7.Manual Testing 123 4. ShowMessage("Hi from script")' 9.0 Release . . Under Events to Handle scroll the list down and locate the Manual Testing Events node 6.

5 Summary In this section.0 Release . .2. Copyright © 2009 AutomatedQA Corp. We also illustrated how you can interact with manual tests from scripts.124 TestComplete 7 Made Easy 10. we learned about TestComplete's Manual Testing features and constructed a simple manual test using one of the provided sample applications.

Part XI Basic Record and Playback .

To view/change these options select Tools | Options..0 Release .1 Basic Record and Playback Objectives This section demonstrates how to perform basic record and playback tasks including: · Understanding the recording toolbar. · Perform a basic recording. .2 Overview TestComplete has rich Record/Playback functionality allowing you to quickly record new test scripts.. TestComplete has several options that allow you to control how recording is performed. and click the Engines folder and select Recording. · How to use buttons on the Recording Toolbar. · How to start a recording. You should see the following options: Copyright © 2009 AutomatedQA Corp. 11.126 TestComplete 7 Made Easy 11 11.2.

2.Basic Record and Playback 127 11.0 Release .3 Recording Toolbar Anatomy TestComplete Recording Toolbar The TestComplete recording toolbar looks like this: The buttons are as follows: Add Comment to Test Run Tested Application Copyright © 2009 AutomatedQA Corp. .

.2.1 Adding Text The Add Text to Script toolbar button allows you to insert either script or comments into the routine that's currently being recorded. Starting a Recording To start a recording you must have a project loaded.3. Once you have a project loaded there are two ways to begin a new recording: 1. Selecting Test | Record from the TestComplete main menu 2. You can load an existing project or start a new project. Press the Record toolbar button on the Test Engine toolbar: 11.0 Release . Clicking this button displays the Add Text to Script dialog: Copyright © 2009 AutomatedQA Corp.128 TestComplete 7 Made Easy Run a Script Extension Add Checkpoint From the List Start Recording Stop Recording Pause Recording Record Keyword Test Record Low Level Procedure (screen coordinates) Record Low Level Procedure (window coordinates) Record Script Record an HTTP Task More Details Clicking the More Details button will expand the toolbar so that it displays Parent and Object name data for the item underneath the mouse cursor.

3.0 Release . Copyright © 2009 AutomatedQA Corp. button that allows you to insert a line of code that references a specific onscreen object.2 Changing Recording Types The recording toolbar has several buttons (see circled buttons below) that allow you to control the type of recording being performed. .. There is also a Pick Object.Basic Record and Playback 129 Notice there is a checkbox at the bottom that allows you to indicate that the text is to be inserted as a comment. 11.2.. The different recording types are: Record a Keyword Test Record Low Level Procedure based on screen coordinates Record Low Level Procedure based on window coordinates Record a Script (default) Record an HTTP task To switch the type of recording simply click the appropriate button.

0 Release .3.4 Hands on Lab: Perform a Basic Recording Recording a Basic Script 1. .2. To resume a paused test click the Start Recording button.130 TestComplete 7 Made Easy 11. 11.4 Stopping To stop a recording click the Stop button. Clicking the Stop button will close the Recording toolbar and restore the TestComplete main window leaving you in the Code Editor on the newly recorded script. 11.3. Pausing a test allows you to manipulate the application under test or change the environment without recording any of those actions into the script. Create a new project and project suite using the General Purpose Test Project template: Copyright © 2009 AutomatedQA Corp.3 Pausing TestComplete allows you to pause in the middle of a recording by clicking on the Pause button.

exe" and click the OK button 6. 5.0 Release . Type "notepad. Once Windows Notepad starts type "this is a test from TestComplete" 7.. Select Run.5 Summary In this section you learned how to perform basic record and playback tasks. Click the Windows Start button 4..2. Click the Stop button on the recording toolbar to end the recording 11.Basic Record and Playback 131 2. We discussed the functionality available on the toolbar including how to record various types of activity. Click the Record button on the toolbar 3. Copyright © 2009 AutomatedQA Corp. .

Part XII Low Level Procedure .

while in most cases these are not necessary.2.0 Release . if you are trying to Paint in a program like MS Paint or trigger a Hover event inside of Internet Explorer or Firefox. we would have ended up with thousands of lines of script identifying the mouse movement coordinates and clicks. clicks and keystrokes. Start a new project normally in TestComplete as shown in the figure below: Copyright © 2009 AutomatedQA Corp. .2 Recording The reason you want to use the Low Level Procedure feature in TestComplete is when the need arises for recording specific mouse or keyboard operations on the screen for playback that are not automatically recorded during a regular recording session. 1. it is very much necessary that the recorder brings in the valuable mouse and keyboard coordinates. if TestComplete would record every mouse and keyboard operation automatically during each recording session. On the other hand. For example.1 Low Level Procedure Objectives In this section you will: · Get a clear understanding of when to use Low Level Procedure · Understand the choices for Low Level Procedure during recording · Understand the editing screen of Low Level Procedure after the recording session · How to play back a Low Level Procedure session successfully 12.Low Level Procedure 133 12 12.

If you forget. no worries. Copyright © 2009 AutomatedQA Corp. Make sure to enable Low Level Procedure Collection in the Project Wizard. .0 Release . You will still be able to add it to the project after the fact using the Add New Item menu of the project in the Project Explorer.2.134 TestComplete 7 Made Easy 2.

0) coordinates starting from top most left window under recording. Tip: For a smoother playback and easier implementation between different resolutions on the screen. which sets the (0. which automatically set the coordinates for the recording as (0.Low Level Procedure 135 3. On the recording tool bar are two buttons that enable Low Level Procedure recording: · The Screen Coordinates based button.0) to be the top most left of the screen. .2. When you start a recording session in TestComplete. you are presented with the recording tool bar shown below. Copyright © 2009 AutomatedQA Corp. we recommend the "Window Coordinates" button to be used. · The Window Coordinates based button.0 Release .

136

TestComplete 7 Made Easy

12.3

Hands on Lab: MS Paint Test
In this lab, we will record a Low Level Procedure to sign a name on the screen with MS Paint. 1. Start a new Project 2. Enable Low Level Procedure Collection in the Wizard. 3. Start MS Paint in the Windows Directory or System32 directory depending on your version of Windows. 4. Start recording 5. Choose the Low Level Procedure - window coordinates button from the recording toolbar. 6. Drag the button from step 5 above to the MS Paint main window of the application until you see a red line around the entire MS Paint window. 7. The Create Project item dialog below will appear. Name your collection "MSPaintCollection" and click OK to close the dialog.

8. Start signing your name or painting anything in the MS Paint application

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Low Level Procedure

137

9. Upon completion of your masterpiece, stop the recorder from the TestComplete recording toolbar. 10. Notice that TestComplete did not record any of the clicks on the MS Paint application, but added one line of code to function Test1 to execute the collection of mouse movements and clicks collected during the recorded session.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

138

TestComplete 7 Made Easy

11. TestComplete collected all the mouse movement and clicks from the recorded session into an LLCollection item in the project called "MSPaintCollection" (see above). 12. Double click the MSPaintColection item in the project Explorer. 13. Notice the 900 + entries that were added to the collection to record all the mouse movement and clicks.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Low Level Procedure

139

14. Each record contains the mouse operation (down, up, move), the number of the operation, the event name itself, the parameters of the mouse at that time (X & Y coordinates) and finally the delay in milliseconds between operations. 15. The nice thing about this workspace area is that you are able to modify 1 or a bunch of these 900 records at will. You can reduce the amount of time between operations, delete meaningless mouse movements that are not needed or even change the mouse coordinates on the screen after the fact.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

140

TestComplete 7 Made Easy

You can now try to playback the recording by running the routine. What happened? Are you surprised? Well, you probably saw the mouse moving on top of the TestComplete Editor in a pattern exactly as you expected would happen in MS Paint. That is because nothing caused the MS Paint application to come to the front or be activated. To fix that issue for your script, always activate the window that needs to be focused and top-most before running your low level procedures.

[JScript] function Test1() { Sys.Process("MSPAINT").Window("MSPaintApp", "*").Activate(); LLCollection1.MSPaintCollection.Execute( Sys.Process("MSPAINT").Window("MSPaintApp", "*")); }

12.4

Summary
In this section we covered how and when to use a Low Level Procedure, recording choices, editing a recording and used the Low Level procedure workspace to change coordinates, delays and events. We also fixed a situation where the testing environment did not work as first expected.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Part

XIII
Stores and Checkpoints

0 Release . The baseline is stored in the Project Item called "Regions" under the Project Item called "Stores". A Region Checkpoint can be created either while recording or from the toolbar at test design time.142 TestComplete 7 Made Easy 13 13. .1 Stores and Checkpoints Objectives This section explores how to compare various testing input including visual areas of the screen. · How to compare multiple properties of an object. · How to create a Region Checkpoint. In this section you'll learn: · What a Region is. files and objects.2 Region Checkpoints Region Checkpoints allow for the comparison of an area of the screen with a baseline. · How to do a File Comparison. 13. Copyright © 2009 AutomatedQA Corp.2.

Open Internet Explorer to www.0 Release .google.Stores and Checkpoints 143 Creating a Region Checkpoint Interactively An example of creating a region checkpoint: 1. Click Create Region Checkpoint from the Editor's Tools toolbar of TestComplete. 3. Copyright © 2009 AutomatedQA Corp.2. . 2. Open a project in TestComplete. 4. Add the Stores project item if not already in the TestComplete project.com.

2. . Use the Finder tool to select the Google logo Copyright © 2009 AutomatedQA Corp. 6.0 Release .144 TestComplete 7 Made Easy 5.

Copyright © 2009 AutomatedQA Corp.Stores and Checkpoints 145 7.2. .0 Release .

. Copyright © 2009 AutomatedQA Corp.2.146 TestComplete 7 Made Easy 8.0 Release .

true. 10.imageLogo. Aliases.imageLogo.iexplore. True.") End If End Sub [JScript] function RegionCompareExample() { if(!Regions. Name the picture "imageLogo" and click OK in the "Create Region Checkpoint" dialog.Compare("imageLogo". Copy the code into a method in TestComplete.pageGoogle. False.iexplore. 0)) Then Call Log.0 Release . 11. No errors should be part of the test log.Error("The regions are not identical.Error("The regions are not identical. Aliases.Sys."). Copyright © 2009 AutomatedQA Corp. False. 0)) Log. [VBScript] Sub RegionCompareExample If (Not Regions.2. The tolerance property is measured in PIXELS and will allow you to define how many pixels can differ between the two regions before the compare would error out. false.Sys. false.Compare("imageLogo".Stores and Checkpoints 147 9.Run the method.pageGoogle. . } 12.

0 Release . There will be an error in the test log. 14.Double-click on the Regions project item to bring up the editor. .Notice that the Tooltip saying "Google" is part of the image 15.148 TestComplete 7 Made Easy 13.Run the method again.2. Copyright © 2009 AutomatedQA Corp.

· The second picture in the log is the actual image. Copyright © 2009 AutomatedQA Corp. .0 Release . · The third picture in the log (the one shown) is the difference between the two images (shown in red pixels).2.Stores and Checkpoints 149 The log results show: · The first picture in the log is the expected image (the one stored in the Region project item).

Link(0). 0).Page("http://www.com/").Cell(1. Cell(1.Compare(Regions. 0).Image("nav_r1_c1").Picture(). . _ Table(0).google.google.2.Link(0).Image("nav_r1_c1").com/"). Page("http://www.Process("iexplore").Process("iexplore").Table(0). then select Engines | Stores.0 Release .150 TestComplete 7 Made Easy Creating a Region Checkpoint in Script Image comparison can also be done by using the Picture object of any OnScreen Object: [VBScript] Sub PictureComplareExample if not Sys.GetPicture("Logo")) then Call Log. Compare(Regions.Error("The OnScreen Object is different") End if End Sub [JScript] function PictureCompareExample() { if (!Sys. · Comparing file hash values (see Hash Values below). · A third-party difference engine. Settings for the third party difference engine can be set through Tools | Options to open the Options dialog.3 File Comparisons TestComplete can compare files using: · A simple byte by byte comparison (Checkpoint) of two files.Error("The OnScreen Object is different") } } 13. _ Picture. Copyright © 2009 AutomatedQA Corp.GetPicture("Logo"))) { Log.

. Copyright © 2009 AutomatedQA Corp.Stores and Checkpoints 151 Create a File Checkpoint To create a File Checkpoint: 1.0 Release . Select File Checkpoint from the "Tools" toolbar.2.

You can find them either on disk or using the "Files" Project Item.152 TestComplete 7 Made Easy 2.") End If End Sub [JScript] Copyright © 2009 AutomatedQA Corp. If you know the files are different and want to compare them.Compare("Sample1. [VBScript] Sub FileCompareExample If (Not Files. . click the "Calculator" button next to the Hash value edit box. Select two files to compare. 0. 3.txt".Error("The files are not identical.txt". 5. 4. This will display the Create File Checkpoint dialog. True)) Then Call Log.0 Release .2. 6. "Sample2. Copy the code to a new method. Press the OK button.

0" standalone="yes" ?> <Contacts> <Contact> <Name>Eric</Name> <Company>Falafel</Company> <Phone>888 GOT-FALAFEL</Phone> </Contact> <Contact> <Name>Lino</Name> <Company>Falafel</Company> <Phone>888 GOT-FALAFEL</Phone> </Contact> <Contact> <Name>Drew</Name> <Company>AutomatedQA</Company> <Phone>(978) 236-7900</Phone> </Contact> <Contact> <Name>Derek</Name> <Company>AutomatedQA</Company> <Phone>(978) 236-7900</Phone> </Contact> Copyright © 2009 AutomatedQA Corp.Compare("Sample1. 0.XML)] <?xml version="1.0" encoding="utf-8" ?> <Contacts> <Contact> <Name>Eric</Name> <Company>Falafel</Company> <Phone>888 GOT-FALAFEL</Phone> </Contact> <Contact> <Name>Lino</Name> <Company>Falafel</Company> <Phone>888 GOT-FALAFEL</Phone> </Contact> <Contact> <Name>Drew</Name> <Company>AutomatedQA</Company> <Phone>(978) 236-7900</Phone> </Contact> <Contact> <Name>Derek</Name> <Company>AutomatedQA</Company> <Phone>(978) 236-7900</Phone> </Contact> </Contacts> [XML (Test. consider the two xml files below: [XML (Contacts. } Using Hash Values If there are known difference between files.").txt". For example.txt".0 Release .2. .Error("The files are not identical. you can still compare the files by using a hash value. true)) Log. "Sample2.XML)] <?xml version="1.Stores and Checkpoints 153 function FileCompareExample() { if(!Files.

0 Release .2. .1812515919.XML". [VBScript] Files. Create Object Checkpoint can be invoked with either the recording toolbar or the "Tools" toolbar: Copyright © 2009 AutomatedQA Corp.Compare("Contacts.XML") Note: Use the XML checkpoint to compare XML files."Test.XML" is the first file the hash value is 1883158225.True) [JScript] Files. To compare these two files.XML". For example."Test. if "Test.XML".XML".154 TestComplete 7 Made Easy <Contact> <Name>Test</Name> <Company>Test</Company> </Contact> </Contacts> If there are known difference between files. consider the two xml files below. 13.1812515919. The hash value from TestComplete if "Contacts.CalculateHashValue("Contacts. So the order of the comparison makes a difference in what the final hash value used in the Compare() function is.4 Object Comparisons Object Comparisons allow the comparison of multiple properties of an Onscreen Object (and the children of that object. you can still compare the files by using a hash value.XML". the code would look like the example below: Caution: The order that the files are compared makes a difference in the calculated Hash Value.true) To get the hash value for two files: [VBScript/JScript] Hash = Files.XML" is the first file in the comparison is 1812515919. if desired).Compare("Contacts."Test.

Panel(0). TestComplete will ask if you want to save the properties of the child objects.Process("iexplore"). TestComplete will select certain properties for you for comparison. · Depending on the type of OnScreen object.Compare(Sys.activefocus. "Panel".net/"). · If the object had children. True)) Then Copyright © 2009 AutomatedQA Corp.Stores and Checkpoints 155 · Use the finder icon to select the onscreen object. Any of the unselected properties can be added for comparison. .0 Release .2. Page("http://www. [VBScript] Sub ObjectCompareExample If (Not Objects.

Copyright © 2009 AutomatedQA Corp.XML" in the StoresSampleProgram (File | Save) 8.activefocus. } · TestComplete will report the difference on the first object found with difference only. "Panel". . 9. 10. Picture and a Property Comparing Files 1.Error("The objects are not identical. Page("http://www.) 7. and TestedApps Project Items. Click "Create File Checkpoint" in the recording toolbar.0 Release .Compare(Sys.").") End If End Sub [JScript] function ObjectCompareExample() { if(!Objects.2. 11.XML" in the StoresSampleProgram" (File | Open. Select "Contacts. Open "Contacts. 3. Create a new project with Events.XML" as the second file.XML" as the first file. 13.net/").Process("iexplore"). 5.. Add the "Contacts. Add the "StoresSampleProgram" to the TestedApps.XML" to the "Files" Project Item (Copy to Stores).. 2. Script.Panel(0). 4. true)) Log. Run the "StoresSampleProgram" 6.156 TestComplete 7 Made Easy Call Log. Select "Test. Press the OK button. Stores.5 Hands on Lab: Comparing File. Click the Record button in TestComplete.Error("The objects are not identical. Save the file as "Test.

Keys("Test. Close the "StoresSampleProgram" program. Add a new contact (+ button) and enter contact information. 17.Click("File|Save.Form1 Call w1.Process("StoresSampleProgram") Set w1 = p1.StripMainMenu.textBox3 Call w5.Window("ComboBox"). "&Open").ClickButton Call w1. 11) Call w4.textBox1 Call w4. "Name") Set w4 = w2.") Set w2 = p1."C:\Training\Stores\Test. 19.") Set w2 = p1. 0) w2.XML" (File | Save). Select "Contacts. Save as "Test.ClickCell(4.Window("#32770"..xml".Keys("Test") Call w4.StoresSampleProgram.ClickItem("+") Set w3 = w1. "FolderView").0 Release . . [VBScript] (Your recording maybe different) Sub Test1 Dim p1 Dim w1 Dim w2 Dim w3 Dim w4 Dim w5 TestedApps.Stores and Checkpoints 157 12.Error("The files are not identical.Window("Button".Window("Button".toolStrip1 Call w3.Click("File|Open.Keys("Test[Tab]") Set w4 = w2..Window("Edit"). 15.Click(17. Click Create File Checkpoint in the recording toolbar 16. 18.Run Set p1 = Sys.Keys("Test") Set w5 = w2.XML".XML" as the first file.ClickCell(3.Click(15.0. "Save Contacts File") Call w2.. ClickItem("Contacts. Select "Test. 13.Window("SysListView32".textBox2 Call w4.Window("SHELLDLL_DefView").True)) Then Call Log.Compare("Contacts. 14.xml".Window("#32770".2. "Name") Copyright © 2009 AutomatedQA Corp. "Open Contacts XML") Call w2.Click(71.WinFormsObject("panel1") Set w3 = w2.Window("ComboBoxEx32"). 21. Click the Add button on the Add Text to Script dialog. 6) Call w5..XML" as the second file.ClickButton If (Not Files.XML") w2. "&Save").StripMainMenu. Press the OK button. 20. 4) Call w3. Click the Add button on the Add Text to Script dialog.WinFormsObject("dataGridView1") Call w3.") End If Set w2 = w1. Stop the recording.

"&Yes").Click(53. var w1.Error("The files are not identical.").Close(). var w3. "&Save"). "C:\Training\Stores\Test.") p1.. w3. 7).").ClickButton().StoresSampleProgram.Click("File|Save.Keys("Test").158 TestComplete 7 Made Easy Call w1. TestedApps. 102). "Save Contacts File". ClickButton().Window("#32770". "C:\\Training\\Test. w2 = w1."). "&Yes").Window("ComboBoxEx32"). 0). ClickButton().StripMainMenu. w2 = p1.XML".Click(52. "Save Contacts File"). true)) Log. 5).xml". w1. if(!Files.ClickItem("+"). ClickButton If (Not Files.Click(205. w3.Window("Button".Close End Sub [JScript] function Test1() { var p1.Error("The files are not identical. 1).StripMainMenu..xml".WinFormsObject("panel1").. 0. 0..XML". w1. "FolderView").StripMainMenu.XML". Delete the "Test. w3.Click("File|Open.Window("Button". "&Save"). "Name").Window("#32770". ClickButton p1.. "Open Contacts XML").Window("Button".Window("#32770".0 Release . w3.Window("ComboBox"). w3 = w2.Window("Button".Window("SysListView32". w3.Click("File|Save. if(!Files. "Save Contacts File").. Copyright © 2009 AutomatedQA Corp.XML").xml".Run(). 11).Window("Edit"). w3 = w2. "Save Contacts File". w3 = w2.Window("#32770".textBox1.Compare("Contacts.. p1.StripMainMenu.Window("#32770".xml".") End If w1. w2 = p1. w3.XML" file from your system.Click("File|Save.toolStrip1. "Save Contacts File").Keys("Test").Compare("Contacts.Window("SHELLDLL_DefView").Keys("Test").Error("The files are not identical.Process("StoresSampleProgram"). . w2. 0. w2.textBox2. w1.").Keys("Test.WinFormsObject("dataGridView1"). p1 = Sys. 1).2. p1. ClickItem("Contacts. w2. True)) Then Call Log.Compare("Contacts.").ClickButton(). "C:\\Training\\Test.Click(52.textBox3. w2. w1. "&Open"). true)) Log. "&Save"). w1 = p1.. w1. w3. w2. } 22.ClickCell(4.Window("Button".Window("#32770".Window("Button". var w2.Form1. w3 = w2.

XML" in the StoresSampleProgram" (File | Open. Run the new method. Click the record button in TestComplete 2.0 Release . . Run the "StoresSampleProgram" 3. The test log will show a file comparison error.) 4.. 5.Stores and Checkpoints 159 23.. Click the "Create Region Checkpoint" in the recording toolbar.2. Comparing Regions (Images) 1. Use the finder tool to select the grid from the "StoreSampleProgram" Copyright © 2009 AutomatedQA Corp. Open "Contacts.

Run Set p1 = Sys. [VBScript] Sub Test2 Dim p1 Dim w1 Dim w2 TestedApps.xml". "FolderView"). 7.Error("The regions are not identical.Window("#32770".") End If w1. "&Open").") Set w2 = p1. .ClickButton If (Not Regions.160 TestComplete 7 Made Easy 6.0 Release .StoresSampleProgram.WinFormsObject("Form1").Window("Button". Close the "StoresSampleProgram" 9.. False. Stop the recording.StripMainMenu. Sys.Click("File|Open.. Click the "Add" button in the "Add Text to Script" dialog.Form1 Call w1.Compare("WinFormsObject_dataGridView". Push the "OK" button. 0) w2.Process("StoresSampleProgram"). "Open Contacts XML") Call w2. 8. Run the new method. 0)) Then Call Log.Window("SHELLDLL_DefView").2. 10.Close End Sub [JScript] function Test2() { Copyright © 2009 AutomatedQA Corp.Process("StoresSampleProgram") Set w1 = p1. WinFormsObject("dataGridView1"). True. ClickItem("Contacts.Window("SysListView32".False.

w2. Run the method. Add the line below before the If in the code. Click the record button in TestComplete Copyright © 2009 AutomatedQA Corp. var w2. 0). w2. 12. } 11."). ClickItem("Contacts. var w1.Window("#32770". "FolderView")..Window("SHELLDLL_DefView"). WinFormsObject("dataGridView1").ClickCell(1.Run().Compare("WinFormsObject_dataGridView".StripMainMenu.Close().Stores and Checkpoints 161 var p1. TestedApps. w1. if(!Regions."). Comparing A Single Property 1.. true.WinFormsObject("Form1"). . p1 = Sys.Window("Button".Process("StoresSampleProgram").Click("File|Open.0 Release . [VBScript] Call w1. "Open Contacts XML").2.WinFormsObject("dataGridView1"). "Name") [JScript] w1.Error("The regions are not identical.WinFormsObject("dataGridView1").false.Window("SysListView32".ClickCell(1.Process("StoresSampleProgram"). "Name"). 0)) Log. w2 = p1. false.Form1.StoresSampleProgram.xml". . "&Open"). Sys.ClickButton(). w1 = p1. w1.

6...162 TestComplete 7 Made Easy 2. Open "Contacts. Click the ellipse button (. 7.XML" in the StoresSampleProgram" (File | Open. Run the "StoresSampleProgram" 3. .0 Release ... User the finder tool to select the DataGrid.) on the Property textbox. 8. Select the "RowCount" property.) 4. Click the "Add" button in the "Add Text to Script" dialog Copyright © 2009 AutomatedQA Corp. Click the "Create Property CheckPoint" 5.2.

w3 = w2.Window("SysListView32". TestedApps. WinFormsObject("dataGridView1").Form1 Call w1. "FolderView"). WinFormsObject("dataGridView1"). . 13.StoresSampleProgram. w1.2.Error("The property value does not equal the template value. Copyright © 2009 AutomatedQA Corp.") End If w1. "FolderView"). Stop the record. Close the "StoresSampleProgram" 10.WinFormsObject("Form1").").6 Summary In this section we learned about Region (Images) and how to compare two regions.Click("File|Open.Process("StoresSampleProgram").StripMainMenu. w2. p1 = Sys. var w1. w3..ClickButton().Error("The property value does not equal the template value. } 11.Process("StoresSampleProgram") Set w1 = p1. "&Open"). 0).Window("SHELLDLL_DefView").xml". "Open Contacts XML") Call w2.ClickButton If (Sys. We learn how TestComplete compares files.0 Release .StoresSampleProgram. "Open Contacts XML").Form1.Window("#32770".Stores and Checkpoints 163 9..ClickItem("Contacts.RowCount <> 5) Then Call Log. "&Open").Window("SysListView32".WinFormsObject("Form1"). [VBScript] Sub Test3 Dim p1 Dim w1 Dim w2 TestedApps. ClickItem("Contacts. 0). w3.Process("StoresSampleProgram"). w1 = p1.StripMainMenu. w1.ClickItem("Log".Window("Button". w2 = p1..Close End Sub [JScript] function Test3() { var p1.Window("Button".") Set w2 = p1.Run(). var w2.xml". var w3. 0) w2."). Run the routine.Process("StoresSampleProgram").Close().. And also how to compare multiple properties of an OnScreen object.Window("#32770".Click("File|Open.Run Set p1 = Sys.RowCount != 5) Log. if(Sys.Window("SHELLDLL_DefView").

Part XIV Data-Driven Testing .

ExcelDriver. 14.2. .ini file)."user1"."admin" 2. · Next: Move to the next record in the data source The DDT plug-in supports the creation of three different types of drivers.0 Release . Example: Case. · Name: The Name of the Driver.2 Overview The Data Driven Plug-In (DDT) uses ADO to access different data elements. · ColumnName: The name of a given column from the data source. For example suppose we have a script that enters a word into notepad: [VBScript] Copyright © 2009 AutomatedQA Corp. · The different type of drivers available.Data-Driven Testing 165 14 14. In this section you'll learn about: · The data driven plug-in.Password 1. · ADODriver is a generic driver to read in ADO compatible data source."pass1" · ExcelDriver is used to read an Excel spreadsheet. such a text files. Once a driver has been initialized. The first row of the sheet is the header information for the driver. · DriveMethod: Iterates through all the records of the database. 14. CSVDriver.1 Data-Driven Testing Objectives This section covers how the Data Driven Testing plug-in consumes various common data types.3 Modifying Scripts You can modify a simple data entry script to use an outside data as an input source. Excel Spreadsheets. and executes a script routine for each record.User. · Value: Returns the value of a column based on the column name or index."admin". · EOF: Indicates if the driver is at the end of the data source. and ADODriver: · CSVDriver is used to read text files. These methods/properties are: · ColumnCount: The number of columns in the data source. such as comma delimited (default) or tab delimited (using a schema. By default the first row is the header information (or column names) for the driver. · How to modify a script to use a driver. the DDT plug-in provides a common interface to columns and rows in the data source. or any ADO compatible database.

105).Window("Edit") w2. "*") Set w2 = w1.\SQLExpress" ' Create Driver Set MyDriver = DDT.VScroll." & _ "Persist Security Info=False.VScroll.166 TestComplete 7 Made Easy Sub Test1 Dim p1 Dim w1 Dim w2 Set p1 = Sys.Pos = 0. "*").Test1") End Sub Sub Test1 Dim p1 Dim w1 Dim w2 Dim KeyStr Set p1 = Sys. LastName FROM" & _ " Sales. FirstName.Process("Notepad") Set w1 = p1. In the example below we create a list of customers from the AdventureWorksDB: [VBScript] Dim MyDriver Sub Main Dim SQLStatement Dim ConnectionString ' Start Notepad TestedApps.Data Source=.Value("CustomerID")& ". w1.Window("Edit").0 Release .Pos = 0 ' Create String with Customer Information KeyStr = MyDriver.vIndividualCustomer" ConnectionString = "Provider=SQLOLEDB. } We can modify the script to enter in multiple words from an outside data source.Window("Edit") w2. "*") Set w2 = w1. .Keys("TestComplete").ADODriver(ConnectionString.Window("Notepad". w1." & _ Copyright © 2009 AutomatedQA Corp.SQLStatement) ' Call Method 100 times MyDriver. 26) Call w2.Process("Notepad") Set w1 = p1.DriveMethod("Unit1.Process("notepad").Notepad.Window("Notepad". w1 = Sys. w1.2." & _ "Initial Catalog=AdventureWorks.VScroll.Pos = 0 Call w2.Click(274.Keys("TestComplete") End Sub [JScript] function Test1() { var w1.Run ' Limit to 100 records SQLStatement = "SELECT TOP (100) CustomerID.1.Integrated Security=SSPI.Window("Notepad".Click(144.

4 Hands on Lab: Modifying Recording for Data-Driven Testing 1.0 Release . Most of the work is in the setup of the driving method." + MyDriver. This example illustrated connecting to an MS SQL database using an ADO Driver. // Call Method 100 times MyDriver. w1." + "Initial Catalog=AdventureWorks.DriveMethod("Unit1.ADODriver(ConnectionString.Process("notepad"). w1.SQLStatement).\\SQLExpress". w1 = Sys. // Start Notepad TestedApps. . // Limit to 100 records SQLStatement = "SELECT TOP (100) CustomerID.Keys(KeyStr).Pos = 0. Create a new project and project Suite. w1.Value("CustomerID")+ ". 14.Keys( KeyStr) End Sub [JScript] var MyDriver function Main() { try { var SQLStatement." + "Persist Security Info=False. 2. Add the “All Pairs Sample” Sample Application Copyright © 2009 AutomatedQA Corp. KeyStr = MyDriver.Value("FirstName")& ". ConnectionString = "Provider=SQLOLEDB.Integrated Security=SSPI.Window("Notepad".description). } As you can see there is very little modification of the initial recording needed to make it ready for Data Driven Testing." & _ MyDriver.Notepad.Value("LastName")& "[Enter]" Call w2. "*"). exception." + MyDriver.Value("LastName")+ "[Enter]".vIndividualCustomer".VScroll.Error("Exception".Value("FirstName")+ ". var ConnectionString. FirstName. // Create Driver MyDriver = DDT.1. var KeyStr.Test1") } catch(exception) { Log.Data Source=.Click(274.Window("Edit"). LastName FROM" + " Sales. 105).Run().Data-Driven Testing 167 MyDriver. } } function Test1() { var w1.2.

wPosition = 10 Set w2 = w1. 5. 11.MainForm w1.ClickButton Call w2. 6.ClickItem("Fair Share") Call w1. Click Record in TestComplete 7.WinFormsObject("button1"). . Select Fair Share from the Allocation Strategy Combo Box 9. Check mark the Greedy checkbox. Stop the recording. and click Yes on the Add Files to Stores dialog. Add the TestData. Click the Run Button 12. Select Fair Share from the Allocation Strategy Combo Box again.ClickItem("Fair Share") End Sub [JScript] function Test5() { var w1.WinFormsObject("trackBar1").168 TestComplete 7 Made Easy 3. This is important for later as this causes the error message to be posted into the correct test case.WinFormsObject("checkBox3"). Run the "All Pairs Sample" application. right-click the Files and select Add New Item… 4.0 Release .ClickButton w1. var w2.txt and the Schema. Under the Stores Project Item. Copyright © 2009 AutomatedQA Corp.Process("All Pairs Sample").2. 13. [VBScript] Sub Test1 Dim w1 Dim w2 Set w1 = Sys.ClickItem("All Stores") w1. Select All Stores from Store Selection Combo Box 10.ini files to the Stores. Select 10 from the track bar in the sample application 8.WinFormsObject("comboBox1") Call w2.WinFormsObject("comboBox2").

w2.CurrentDriver. In the parentheses.CSVDriver(Files.ClickItem("Fair Share").DriveMethod()".txt")). } 14.WinFormsObject("checkBox3").txt")) DDT. type in “TestData. DDT. See the example code snippet below. w1.WinFormsObject("comboBox2"). 19.Test1"). w2.Test1") End Sub [JScript] function Main() { DDT.wPosition = 10.ClickItem("Fair Share"). 16.MainForm Copyright © 2009 AutomatedQA Corp. add “Unit1. w2 = w1.0 Release . [VBScript] w1.Checked = true.CurrentDriver.txt” (including the quotes). Modify the checkbox line to get rid of the call to Click Button() substitute Checked = true. Inside the FileNameByName parentheses.Process("All Pairs Sample"). Type in "DDT.WinFormsObject("trackBar1"). Move the cursor inside the parentheses.2.MainForm. Now to modify the inputs.WinFormsObject("button1").Checked = true [JScript] w1. 21.CSVDriver()" 17.ClickButton().ClickButton().AppendFolder(DDT. Type in "DDT.CSVDriver(Files. In the main routine add a new line.Value("case")) Set w1 = Sys.Data-Driven Testing 169 w1 = Sys.WinFormsObject("checkBox3"). w1. We now need to create a routine for reading the data file.Process("All Pairs Sample").DriveMethod("Unit1. Add a new line. Your script should now look something like the example below: [VBScript] Sub Main DDT. 15.WinFormsObject("checkBox3").DriveMethod("Unit1. type in "Files. } 22.CurrentDriver.FileNameByName()" 18.WinFormsObject("comboBox1").ClickItem("All Stores"). w1.Test1”. change the input lines to: [VBScript] Sub Test1 Dim w1 Dim w2 Log. .CurrentDriver.FileNameByName("TestData. 20. w1.FileNameByName("TestData.

w1. w2 = w1.Value("Strategy")) w1.AppendFolder(DDT. Run the project. Log.ClickItem("Fair Share") Log.CurrentDriver.CurrentDriver.Value("Iterations").Value("Greedy") == "Y").WinFormsObject("comboBox1").WinFormsObject("checkBox3"). } 23. w1.Checked = (DDT.Value("case")).CurrentDriver.2. There will be an unexpected window during the test run that TestComplete will handle.Value("Stores")) Set w2 = w1.170 TestComplete 7 Made Easy w1.CurrentDriver. Caution: DO NOT TOUCH THE COMPUTER WHILE THE TEST IS RUNNING.WinFormsObject("checkBox3").Value("Greedy") = "Y") w1. Log.MainForm. ClickItem(DDT.WinFormsObject("button1").Value("Stores")). var w2.ClickButton().ClickItem("Fair Share").wPosition = DDT. w2.ClickItem(DDT. w1. w1 = Sys.Value("Iterations") Call w1.WinFormsObject("button1").Checked = (DDT.ClickItem(DDT.0 Release . The test log should look something like the example screenshot below: Copyright © 2009 AutomatedQA Corp.Process("All Pairs Sample").wPosition = DDT.WinFormsObject("trackBar1").ClickItem(DDT.CurrentDriver.WinFormsObject("comboBox2"). w2.CurrentDriver.WinFormsObject("comboBox2"). w1.PopLogFolder().ClickButton Call w2. .CurrentDriver.CurrentDriver.WinFormsObject("trackBar1").Value("Strategy")).CurrentDriver.PopLogFolder() End Sub [JScript] function Test5() { var w1.WinFormsObject("comboBox1") Call w2.

Data-Driven Testing

171

14.5

Summary
In this section we learned about how the DDT plug-in works and the different types of drivers. We learned how to modify a script to get values from the DDT driver.

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Part

XV
Event Handling

Event Handling

173

15
15.1

Event Handling
Objectives
This section explains how to respond to events that occur during testing. In this section you'll learn about: · What Events are. · How to create script code that responds to an event. · How to respond to unexpected windows.

15.2

General Events Definition
Events occur based on certain actions and activities that occur in TestComplete, or some other application that is being tested. For example, every time an error is logged (by TestComplete or your script), TestComplete generates an OnLogError event. TestComplete has a rich set of events for handling common scenarios: General Events
Name OnLogCloseNode OnLogCreateNode OnLogError OnLogEvent OnLogFile OnLogLink OnLogMessage OnLogPicture OnLogWarning OnOverlappingWindow OnTimeout OnUnexpectedWindow OnValidate Description Occurs when a log folder is pop off the log. Occurs when a new log folder is appended on the log. Occurs when an error message is posted to the log. Occurs when an event message is posted to the log. Occurs when a file is posted to the log. Occurs when a file reference (link) is posted to the log. Occurs when a information message is posted to the log. Occurs when a picture (image) is posted to the log. Occurs when a warning message is posted to the log. Occurs when a overlapping window appears. Occurs when a timeout expires in a project or project suite. Occurs when an unexpected window appears. Occurs when the objects Validate method is called.

HTTP LoadTesting Events
Name Description

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

174

TestComplete 7 Made Easy

OnLoadTestingRequest OnLoadTestingResponse

Occurs just before TestComplete send an HTTP request to the tested Web Server. Occurs just after TestComplete receives a response to an HTTP request.

Manual Testing Events
Name OnBeforeStep OnGetNextStep Description Occurs before the next step is display to the user Occurs when TestComplete get the information about what the next step is to be executed Occurs when a manual test is about to be resumed. Occurs when a user click the Fail button in the Step Dialog Occurs when a user click the Success button in the Step Dialog Occurs when the manual test is suspended Occurs when the user stops the manual test.

OnResume OnStepFailed OnStepSuccess OnSuspend OnTestStep

NetworkSuite Events
Name OnNetJobStateChange OnNetSuiteStateChange OnNetTaskStateChange OnNetVarChange Desciption Occurs when a job's state changes. Occurs when the Network Suite's state changes. Occurs when a task's state changes. Occurs when the value of a Network Suite variable changes.

Test Engine Events
Name OnStartTest OnStopTest Description Occurs when a TestComplete test starts. Occurs when a test is over.

Web Testing Events
Name OnWebBeforeNavigate Description Occurs before the browser navigates to the specified web page

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

Event Handling

175

OnWebDownloadStarted

Occurs when the download of a web page is starting.

OnWebDownloadComplete Occurs when the download of a web page has completed, failed or halted. OnWebPageDownloaded Occurs after the browser loads the specified page (or frame) OnWebQuit Occurs before the browser closes.

15.2.1 OnLogError
One of the most commonly used events, OnLogError can be used to gather addition information about the state of the system when the error occurred. For example: 1. Expand the "Events" Project Item. 2. Double click the "GeneralEvents" Project Item. 3. Add an "OnLogError" handler to your project by clicking the new button next to the OnLogError event .

4. Click the OK button in the "New Routine" dialog. TestComplete will create a new routine for you with two parameters: "Sender," which represents the event handler controller and "LogParams," which contains information on the message just about to be posted to the TestComplete log file. Note: If you set LogParams.Locked = true, TestComplete will not post a message at all to the log. The following code will post a picture of the desktop to the test log along with a duplication of the error

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

176

TestComplete 7 Made Easy

message:

[VBScript] Sub GeneralEvents_OnLogError(Sender, LogParams) Call Log.Picture(Sys.Desktop,LogParams.Str) End Sub

[JScript] function GeneralEvents_OnLogError(Sender, LogParams) { Log.Picture(Sys.Desktop,LogParams.Str) }

15.3

Unexpected Windows
An unexpected window is defined by TestComplete as a modal dialog (a window that wants all keyboard and mouse activity for the application) that opens up over the application under test AND TestComplete is trying to interact with one of the other windows of the application under test. TestComplete has default handling for an unexpected window if "Ignore unexpected window" is not checked:

Copyright © 2009 AutomatedQA Corp. - 2.0 Release

the test will stop. 7. 4. 8. Enter "1" in to each of the edit boxes. 2. TestComplete will then attempt to close the unexpected window and continue the test. Send an Enter key to the window (if checked in playback options). 3. Click the record button in TestComplete. If "Stop execution" is checked (playback options). Comment out the code for the setting the value of the "numericUpDown2" control. 9. Add the UnexpectWindow Application to the TestedApps project Item. Create a project in TestComplete. If "Stop On Error" is checked (playback options). . Clicks the focused button (if checked in playback options). Logs an Error with a picture of the unexpected window. If TestComplete gets here without being able to close the unexpected window. start the UnexpectedWindow application.4 Hands on Lab: Create Unexpected Window Handler 1.Event Handling 177 Default Unexpected Window Handling Behavior TestComplete performs the following when an unexpected window appears: 1. 10. Send an ESC key to the window (if checked in playback options). Close the application and stop the recording. 3. 6. Waits for the window to disappear on its own up to the Auto-Timeout period (10 seconds by default). 2. 6. From the recording toolbar. 7. 11. 5. Click the "Calculate" button. Calls the OnUnexpectedWindow event handler if any have been defined. Send a WM_CLOSE message to the window (if checked in playback options). 15.0 Release . 9. Run the created script. 4. Example Script: [VBScript] Sub Test1 Copyright © 2009 AutomatedQA Corp. 5. the test will stop.2. 8. the test will stop.

Close End Sub [JScript] function Test1() { var w1.WinFormsObject("UpDownEdit".WinFormsObject("numericUpDown2"). w2 = w1.WinFormsObject("UpDownEdit". we will create a event handler for the unexpected window that will retrieve this information. .Keys("1[Tab]") 'Call w1.UnexpectedWindow.Click(). } You will get an unexpected window.WinFormsObject("button1"). Keys("1"). Keys("1") w1.Process("UnexpectedWindow"). w2. "") Call w2. w2.WinFormsObject("numericUpDown1").ClickButton w1.2. "").UnexpectedWindow.Run(). ""). w1.WinFormsObject("numericUpDown2").Keys("1[Tab]").WinFormsObject("UpDownEdit". So.Close(). w1.Run Set w1 = Sys.UnexpectedWindow Set w2 = w1. //w1.Click() Call w2. var w2.WinFormsObject("numericUpDown1").Process("UnexpectedWindow").WinFormsObject("button1"). Copyright © 2009 AutomatedQA Corp.ClickButton(). This unexpected window contains additional information that the developer can use to track down the issue. w1 = Sys.UnexpectedWindow.0 Release . TestedApps.178 TestComplete 7 Made Easy Dim w1 Dim w2 TestedApps.

Expand the Events Project Item. Double-click the GeneralEvents Project Item.Event Handling 179 10.2. Copyright © 2009 AutomatedQA Corp. 12. . 11.0 Release . Click the new Button next to the OnUnexpectedWindow event in the GeneralEvents Editor.

0 Release .WinFormsObject("TextBox". .Message("Additional Error Information".180 TestComplete 7 Made Easy 13. Copyright © 2009 AutomatedQA Corp. } 15. Window.2.Text).Message("Additional Error Information". In the event add the following code: [VBScript] Sub GeneralEvents_OnUnexpectedWindow(Sender. Run the created script from above. ""). Window.WinFormsObject("TextBox".Text) End Sub [JScript] function GeneralEvents_OnUnexpectedWindow(Sender. _ Window. LogParams) Call Log. ""). Window. 14. LogParams) { Log. Click the OK button.

5 Summary In this section.2. During this time. . we learned about one of the most important events caused by unexpected windows and different options for handling unexpected windows. Copyright © 2009 AutomatedQA Corp.0 Release . We have also learned how to attach script code to events.Event Handling 181 15. we have learned about events and the types of events that TestComplete provides.

Part XVI Working with Databases .

CreateADOQuery. CreateADOStoredProc. · How to retrieve ADO data and use the data in your tests. The table below shows the available methods: Microsoft CreateCommand CreateConnection Borland CreateADOCommand CreateADOConnection CreateADODataSet CreateADOQuery CreateADOStoredProc CreateADOTable The following Borland methods are specialized extensions of CreateADOCommand: CreateADODataSet.com. You can get this information from the developer of the project you're testing. To query a database using ADO: Copyright © 2009 AutomatedQA Corp.connectionstrings. One of the hardest parts to using ADO is getting the connection string correct. TestComplete offers two implementations to access ADO datasources.0 Release .Working with Databases 183 16 16.NET-only connection string (for example the SqlConnection for SQL Server 2005).1 Working with Databases Objectives TestComplete includes general-purpose mechanisms for connecting to external databases. or look at http://www. You can connect to ActiveX Data Object (ADO) and Borland Database Engine (BDE) data sources.2 ADO ADO stands for "ActiveX Data Object". One route uses native Microsoft methods. · The commands available to manipulate ADO and BDE data sources. Caution: TestComplete can not use the . 16. In this section you will learn: · How to connect to an ADO database. ADO allows TestComplete to access and manipulate data in a variety of data source (mostly databases).2. the other through Borland (Codegear) methods. . CreateADOTable.

adParamInput) ' Specify the parameter value Prm.Connection") ' Specify the connection string AConnection.Integrated Security=SSPI.2.CreateConnection ' Note that you can also create an ADO connection using the following code: ' Set AConnection = CreateObject("ADODB.EOF Log.com/MSFTDBProdSamples/ Release/ProjectReleases. DB.Open ' Create a new Command object Set Cmd = ADO. Do something with the returned RecordSet. TerritoryID.CommandType = adCmdText ' Create a new parameter Set Prm = Cmd. 3." & _ "Persist Security Info=False.Parameters.Value = "S" Cmd. The example reads through the Sales table.ActiveConnection = AConnection ' Specify command type and text Cmd.MoveFirst While Not RecSet.Value) RecSet.aspx?ReleaseId=4004) and SQL Server 2005.CreateParameter("@CustType"." & _ "Initial Catalog=AdventureWorks.ConnectionString = _ "Provider=SQLOLEDB. Create an Query Command. Execute the Query Command. Close the Connection.Value & " has account " & _ RecSet("AccountNumber").Message(RecSet("CustomerID").\SQLExpress" ' Activate the connection AConnection." & _ " rowguid. 2. The following example uses the AdventureWorkDB (http://www.MoveNext WEnd AConnection.CreateCommand ' To create an ADO command you can also use the following code: ' Set Cmd = CreateObject("ADODB. 5. Create an Connection to the database. logging a customer and account number for each record.Data Source=. ModifiedDate FROM Sales.adVarChar. AccountNumber.184 TestComplete 7 Made Easy 1.codeplex.0 Release .Execute ' Execute the command RecSet.Append(Prm) ' Execute the command Set RecSet = Cmd. 6.DB.CommandText = _ "SELECT CustomerID.Command") ' Specify the connection Cmd. . Open the Connection. [VBScript] Sub Main ' Create a new Connection object Set AConnection = ADO.1. 4. CustomerType.Size= 1 Prm.Customer WHERE (CustomerType = ?)" Cmd.Close End Sub Copyright © 2009 AutomatedQA Corp.

85). // Process the results RecSet.CommandType = adCmdText. AccountNumber. // Specify the parameter value Prm.description). Cmd.Append(Prm).Data Source=. .2. CustomerType. // Note that you can also create an ADO connection using the following code: // AConnection = new ActiveXObject("ADODB.Command").Error("Exception".microsoft.Customer WHERE (CustomerType = ?)" // Create a new parameter Prm = Cmd.MoveFirst().Size = 1.Integrated Security=SSPI.EOF ) { Log. // Specify command type and text Cmd." + " rowguid.ActiveConnection = AConnection. // Create a new Connection object AConnection = ADO.com/en-us/library/ms675532 (VS.Value + " has account " + RecSet("AccountNumber").Value = "S".0 Release . } } For more information on ADO see Microsoft web site (http://msdn2. Cmd.Parameters. } catch(exception) { Log.1. } AConnection.ConnectionString = "Provider=SQLOLEDB. // Create a new Command object Cmd = ADO. Prm.Connection"). Prm.adParamInput). Cmd.MoveNext().\\SQLExpress".CreateCommand(). // To create an ADO command you can also use the following code: // Cmd = new ActiveXObject("ADODB.aspx) Copyright © 2009 AutomatedQA Corp.DB. while (! RecSet.Value) RecSet. // Activate the connection AConnection. TerritoryID. // Execute the command RecSet = Cmd. ModifiedDate FROM Sales. RecSet. exception.Close().Message(RecSet("CustomerID").Open()." + "Initial Catalog=AdventureWorks.Execute().Working with Databases 185 [JScript] function Main() { try { var AConnection.adVarChar." + "Persist Security Info=False. DB.CreateParameter("@CustType".CreateConnection(). // Specify the connection Cmd.CommandText = "SELECT CustomerID. // Specify the connection string AConnection.

· Execute the command and get a result set.Open AConnection. The example below will read the Sales table and extract a total sales figure for a given customer. Create an ADO connection to the server.0 Release .Integrated Security=SSPI.Data Source=.3 Hands on Lab: Query Database In this lab we are going to query the AdventureWorkDB. // Note that you can also create an ADO connection using the following code: // AConnection = new ActiveXObject("ADODB.CreateConnection().Integrated Security=SSPI. adding the following features as we go: · Connect to the ADO datasource. RecSet.186 TestComplete 7 Made Easy 16.ConnectionString = "Provider=SQLOLEDB.SalesOrderDetail AS d INNER JOIN Sales. Prm. .Connection").1. · Iterate the result set." & _ "Initial Catalog=AdventureWorks.Close End Sub [JScript] function Main() { try { var AConnection. 1.2." + Copyright © 2009 AutomatedQA Corp." + "Persist Security Info=False. The parameter will contain the customer number. run the script to make sure the connection string is correct.SalesOrderHeader AS h ON d. [VBScript] Sub Main ' Create a new Connection object Set AConnection = ADO. // Specify the connection string AConnection.Connection") ' Specify the connection string AConnection.ConnectionString = _ "Provider=SQLOLEDB. // Create a new Connection object AConnection = ADO.SalesOrderID = h. The SQL to get the sales order details for any customer is the following parameterized query: SELECT * FROM Sales." & "Persist Security Info=False. Cmd.CreateConnection ' Note that you can also create an ADO connection using the following code: ' Set AConnection = CreateObject("ADODB. · Create an ADO command.CustomerID = ?) In the example we will build the code step-by-step.\SQLExpress" ' Activate the connection AConnection.SalesOrderID WHERE (h. calculate the total sales and log the amount.1. · Create a parameter for the ADO command.

Integrated Security=SSPI.CommandText = "SELECT * FROM Sales.Working with Databases 187 "Initial Catalog=AdventureWorks. // Specify the connection string Copyright © 2009 AutomatedQA Corp.\SQLExpress" ' Activate the connection AConnection.ConnectionString = _ "Provider=SQLOLEDB.Command") ' Specify the connection Cmd. } } 2. Create an ADO command.SalesOrderDetail AS d INNER JOIN " & _ "Sales.2.\\SQLExpress".Connection") ' Specify the connection string AConnection. Prm.0 Release . // Note that you can also create an ADO connection using the following code: // AConnection = new ActiveXObject("ADODB. [VBScript] Sub Main ' Create a new Connection object Set AConnection = ADO. AConnection.Data Source=." & _ "Initial Catalog=AdventureWorks.description).SalesOrderHeader AS h ON d.CreateConnection(). } catch(exception) { Log." & _ "Persist Security Info=False.Close().CommandType = adCmdText ' Create a new parameter AConnection. // Create a new Connection object AConnection = ADO.CustomerID = ?)" Cmd. RecSet. Cmd.Open ' Create a new Command object Set Cmd = ADO.CreateCommand ' To create an ADO command you can also use the following code: ' Set Cmd = CreateObject("ADODB.Open().Data Source=.Connection").Close End Sub [JScript] function Main() { try { var AConnection.CreateConnection ' Note that you can also create an ADO connection using the following code: ' Set AConnection = CreateObject("ADODB. exception.ActiveConnection = AConnection ' Specify command type and text Cmd.SalesOrderID = h. // Activate the connection AConnection.SalesOrderID " & _ " WHERE (h.Error("Exception".1. .

" + "Persist Security Info=False.SalesOrderDetail AS d INNER JOIN" & " Sales.Value = 676 Copyright © 2009 AutomatedQA Corp.CustomerID = ?)" AConnection.CreateCommand ' To create an ADO command you can also use the following code: ' Set Cmd = CreateObject("ADODB. // Specify command type and text Cmd.Size= 4 Prm.SalesOrderHeader AS h ON d.SalesOrderID" + " WHERE (h.ActiveConnection = AConnection.SalesOrderHeader AS h ON d. // To create an ADO command you can also use the following code: // Cmd = new ActiveXObject("ADODB.Command").Error("Exception".Open().CreateConnection ' Note that you can also create an ADO connection using the following code: ' Set AConnection = CreateObject("ADODB. Cmd.\SQLExpress" ' Activate the connection AConnection.CommandText = "SELECT * FROM Sales.SalesOrderID = h. } catch(exception) { Log.1." & _ "Persist Security Info=False.Integrated Security=SSPI.CommandType = adCmdText ' Create a new parameter Set Prm = Cmd.Connection") ' Specify the connection string AConnection.ActiveConnection = AConnection ' Specify command type and text Cmd.DB.CreateParameter("@CustID".ConnectionString = _ "Provider=SQLOLEDB. // Specify the connection Cmd. } } 3.Command") ' Specify the connection Cmd.Integrated Security=SSPI. [VBScript] Sub Main ' Create a new Connection object Set AConnection = ADO.SalesOrderID = h.CommandType = adCmdText.Close().Data Source=. DB. .Open ' Create a new Command object Set Cmd = ADO. exception." & _ "Initial Catalog=AdventureWorks.SalesOrderDetail AS d INNER JOIN " + "Sales.CommandText = "SELECT * FROM Sales.adInteger.CreateCommand(). // Activate the connection AConnection.description).adParamInput) ' Specify the parameter value Prm.2.1.SalesOrderID " & _ " WHERE (h." + "Initial Catalog=AdventureWorks.\\SQLExpress". // Create a new Command object Cmd = ADO.ConnectionString = _ "Provider=SQLOLEDB. Create the parameter for customer number.CustomerID = ?)" Cmd.188 TestComplete 7 Made Easy AConnection.Data Source=.0 Release .

// Specify the connection string AConnection.DB. . AConnection. // To create an ADO command you can also use the following code: // Cmd = new ActiveXObject("ADODB.CustomerID = ?)" // Create a new parameter Prm = Cmd. [VBScript] Sub Main ' Create a new Connection object Set AConnection = ADO.CreateCommand(). // Activate the connection AConnection.0 Release .SalesOrderID = h.SalesOrderDetail AS d INNER JOIN " + "Sales.Working with Databases 189 End Sub [JScript] function Main() { try { var AConnection.adInteger.ActiveConnection = AConnection. RecSet. // Specify the parameter value Prm. // Specify command type and text Cmd.CreateConnection().Data Source=.Value = 676. Cmd. // Create a new Connection object AConnection = ADO.description). Prm." + "Initial Catalog=AdventureWorks.Close().Connection") ' Specify the connection string Copyright © 2009 AutomatedQA Corp.SalesOrderID" + " WHERE (h.adParamInput). // Specify the connection Cmd. Insert the parameter into the command object. DB.CommandText = "SELECT * FROM Sales. exception. Prm. // Note that you can also create an ADO connection using the following code: // AConnection = new ActiveXObject("ADODB. } } 4.Size = 4.Command").CreateConnection ' Note that you can also create an ADO connection using the following code: ' Set AConnection = CreateObject("ADODB.\\SQLExpress".ConnectionString = "Provider=SQLOLEDB.Open().Error("Exception". // Create a new Command object Cmd = ADO.Integrated Security=SSPI. Cmd.CreateParameter("@CustID". } catch(exception) { Log.SalesOrderHeader AS h ON d.1.Connection")." + "Persist Security Info=False.CommandType = adCmdText.2.

Command").adInteger.Size= 4 Prm. // Specify the connection string AConnection.1. // Create a new Connection object AConnection = ADO.CommandType = adCmdText ' Create a new parameter Set Prm = Cmd.SalesOrderDetail AS d INNER JOIN " & _ ":Sales.Integrated Security=SSPI. Prm.SalesOrderID " & _ " WHERE (h.CreateConnection().Close End Sub [JScript] function Main() { try { var AConnection. // Create a new Command object Cmd = ADO.DB.adParamInput) ' Specify the parameter value Prm.CustomerID = ?)" Cmd. Cmd.190 TestComplete 7 Made Easy AConnection.CreateCommand ' To create an ADO command you can also use the following code: ' Set Cmd = CreateObject("ADODB.\\SQLExpress"." & _ "Initial Catalog=AdventureWorks.SalesOrderDetail AS d INNER JOIN " + "Sales. // Specify command type and text Cmd.Integrated Security=SSPI.Append(Prm) AConnection.1.ConnectionString = "Provider=SQLOLEDB.2.Value = 676 Cmd.SalesOrderHeader AS h ON d.CustomerID = ?)" Copyright © 2009 AutomatedQA Corp. // Note that you can also create an ADO connection using the following code: // AConnection = new ActiveXObject("ADODB.SalesOrderHeader AS h ON d.ConnectionString = _ "Provider=SQLOLEDB.SalesOrderID = h.Command") ' Specify the connection Cmd.ActiveConnection = AConnection ' Specify command type and text Cmd. .CommandText = "SELECT * FROM Sales." & _ "Persist Security Info=False.Data Source=." + "Persist Security Info=False.SalesOrderID" + " WHERE (h.ActiveConnection = AConnection.Parameters.\SQLExpress" ' Activate the connection AConnection. DB.Open ' Create a new Command object Set Cmd = ADO." + "Initial Catalog=AdventureWorks. RecSet.CreateParameter("@CustID".Data Source=.Connection").CreateCommand().CommandType = adCmdText. Cmd.CommandText = _ "SELECT * FROM Sales. // To create an ADO command you can also use the following code: // Cmd = new ActiveXObject("ADODB.0 Release .Open().SalesOrderID = h. // Specify the connection Cmd. // Activate the connection AConnection.

Cmd. } } 5.adParamInput). DB.adParamInput) ' Specify the parameter value Prm.SalesOrderID " & _ " WHERE (h." & _ "Initial Catalog=AdventureWorks. Prm.SalesOrderHeader AS h ON d.Parameters.SalesOrderID = h.ActiveConnection = AConnection ' Specify command type and text Cmd." & _ "Persist Security Info=False.Size = 4. exception.DB.Integrated Security=SSPI.adInteger.DB.Value = 676.Open ' Create a new Command object Set Cmd = ADO.Error("Exception".0 Release .Connection") ' Specify the connection string AConnection. DB.adInteger.Working with Databases 191 // Create a new parameter Prm = Cmd.CustomerID = ?)" Cmd.\SQLExpress" ' Activate the connection AConnection.Close().Size= 4 Prm.CommandType = adCmdText ' Create a new parameter Set Prm = Cmd.Command") ' Specify the connection Cmd. [VBScript] Sub Main ' Create a new Connection object Set AConnection = ADO. .Data Source=.CreateConnection ' Note that you can also create an ADO connection using the following code: ' Set AConnection = CreateObject("ADODB.Execute ' Execute the command AConnection.2.CreateParameter("@CustID". AConnection. } catch(exception) { Log.Value = 676 ' Execute the command Set RecSet = Cmd.CreateParameter("@CustID".SalesOrderDetail AS d INNER JOIN " & _ "Sales.Close End Sub [JScript] function Main() { Copyright © 2009 AutomatedQA Corp.Append(Prm).CommandText = _ "SELECT * FROM Sales.CreateCommand ' To create an ADO command you can also use the following code: ' Set Cmd = CreateObject("ADODB. // Specify the parameter value Prm.1.description). Execute the command object and get the ResultSet.ConnectionString = _ "Provider=SQLOLEDB.

adInteger.CreateCommand(). Cmd. // Specify command type and text Cmd.CommandText = "SELECT * FROM Sales.CreateParameter("@CustID".DB. // Note that you can also create an ADO connection using the following code: // AConnection = new ActiveXObject("ADODB.Parameters.Data Source=.Append(Prm).1. Prm.SalesOrderID = h." + "Initial Catalog=AdventureWorks.Command").SalesOrderDetail AS d INNER JOIN " + "Sales. Iterate through the result set to total the orders (this could have been done with a single sql query). // Specify the parameter value Prm. // Specify the connection string AConnection.SalesOrderID" + " WHERE (h.Integrated Security=SSPI. DB.2.\SQLExpress" ' Activate the connection AConnection.Data Source=.1. // Activate the connection AConnection. // Specify the connection Cmd.Connection") ' Specify the connection string AConnection.SalesOrderHeader AS h ON d." & _ "Initial Catalog=AdventureWorks.Value = 676.\\SQLExpress".description).ActiveConnection = AConnection. // Create a new Connection object AConnection = ADO. Cmd.Size = 4. // To create an ADO command you can also use the following code: // Cmd = new ActiveXObject("ADODB.CreateConnection().ConnectionString = "Provider=SQLOLEDB.192 TestComplete 7 Made Easy try { var AConnection.Open()." & _ "Persist Security Info=False. // Create a new Command object Cmd = ADO. exception.Connection")." + "Persist Security Info=False. RecSet.ConnectionString = _ "Provider=SQLOLEDB.Close().CreateConnection ' Note that you can also create an ADO connection using the following code: ' Set AConnection = CreateObject("ADODB. AConnection.Open ' Create a new Command object Copyright © 2009 AutomatedQA Corp. } } 6.adParamInput). Cmd.Integrated Security=SSPI. Prm. . } catch(exception) { Log.CustomerID = ?)" // Create a new parameter Prm = Cmd. // Execute the command RecSet = Cmd.0 Release . [VBScript] Sub Main ' Create a new Connection object Set AConnection = ADO.CommandType = adCmdText.Error("Exception".Execute().

EOF Sales = Sales + VarToFloat(RecSet("LineTotal").Execute ' Execute the command Dim Sales Sales = 0 While Not RecSet.Append(Prm) ' Execute the command Set RecSet = Cmd.2.\\SQLExpress".SalesOrderDetail AS d INNER JOIN " & _ "Sales.adParamInput) ' Specify the parameter value Prm. // Specify the connection string AConnection." + "Persist Security Info=False.Value = 676 Cmd.MoveNext WEnd Log.Parameters. // Specify the connection Cmd. Cmd. // Create a new Command object Cmd = ADO. DB.adInteger.ActiveConnection = AConnection. RecSet.Message("Total Sales = " ^ Sales) AConnection. // Create a new Connection object AConnection = ADO.Size= 4 Prm.Command") ' Specify the connection Cmd. Cmd.CreateConnection().CreateCommand().0 Release .CreateParameter("@CustID".SalesOrderID" & _ " = h.ConnectionString = "Provider=SQLOLEDB. // To create an ADO command you can also use the following code: // Cmd = new ActiveXObject("ADODB.Close End Sub [JScript] function Main() { try { var AConnection.SalesOrderID WHERE (h.CommandText = Copyright © 2009 AutomatedQA Corp.Working with Databases 193 Set Cmd = ADO.CommandText = _ "SELECT * FROM Sales. // Specify command type and text Cmd. // Activate the connection AConnection." + "Initial Catalog=AdventureWorks.Connection").CommandType = adCmdText ' Create a new parameter Set Prm = Cmd.ActiveConnection = AConnection ' Specify command type and text Cmd.CommandType = adCmdText.Data Source=. .DB.Integrated Security=SSPI.Open().1.SalesOrderHeader AS h ON d. // Note that you can also create an ADO connection using the following code: // AConnection = new ActiveXObject("ADODB.Value) RecSet.CustomerID = ?)" Cmd.CreateCommand ' To create an ADO command you can also use the following code: ' Set Cmd = CreateObject("ADODB. Prm.Command").

Value = 676.SalesOrderID = h. Cmd.SalesOrderID" + " WHERE (h. // Execute the command RecSet = Cmd.description).Parameters. // Specify the parameter value Prm. var Sales.4 Summary In this section we discussed options for connecting and manipulating datasources using ADO and BDE. Sales = 0.Close(). while (! RecSet.Append(Prm).Size = 4.CreateParameter("@CustID".Value. AConnection.Error("Exception". } Log. AConnection. exception. } } You should get a log file like: 16. } catch(exception) { Log.2.0 Release .MoveNext().SalesOrderHeader AS h ON d. Copyright © 2009 AutomatedQA Corp.CustomerID = ?)" // Create a new parameter Prm = Cmd.adInteger.adParamInput).Execute().DB.Close().194 TestComplete 7 Made Easy "SELECT * FROM Sales.SalesOrderDetail AS d INNER JOIN" + " Sales. .Message("Total Sales = " + Sales).EOF ) { Sales = Sales + RecSet("LineTotal"). Prm. DB. You learned how to retrieve ADO data for use within your tests. RecSet.

Part XVII Web Page Testing .

only the "A" node part of the Object Browser tree gets updated. This is the slowest method for using web pages. Copyright © 2009 AutomatedQA Corp. the native way that Internet Explorer looks at web pages. · How to find web page object based on properties. · Web Comparison Checkpoint.0 Release . This is the fastest method for using web pages. 3.Document Object Model. 17. while any old TestComplete code using the DOM will continue to work.1 Web Page Testing Objectives This section discusses how TestComplete represents web pages in the Object Browser. This section also talks about strategies for locating and testing dynamic HTML elements. Select Open Application | Web Testing.2 Web Page Model TestComplete supports four web page models: · DOM . · Web Accessibility Checkpoint.This uses both DOM and Tree. · Tree . · TAG .2.196 TestComplete 7 Made Easy 17 17. Select the Project Project Item and then click on Properties. This model creates a very deep tree for most web pages.All HTML elements are sorted by their TAG value. · Hybrid . how to navigate between web pages and how web checkpoints are used. All items on the web page need to be re-read each time the web page is updated. All new recording will use the Tree model. If a link (<A> HTML tag) gets created. · How to handle dynamic HTML elements using mouse hovers. 2. To set the web page model used for the project: 1.Treats a web page like a normal application. Select the desired Tree model. . · How TestComplete names web page elements. The DOM model creates a very flat tree in the Object Browser. In this section you'll learn about: · Web Page Models.

· Tree .gif") .HTML elements are in the form of Item(index). use either the checkpoint drop down from the recording toolbar. Image ("Logo. if any (with the Identification attribute having priority). for example: Panel(0) .4 Web Comparison Checkpoint A Web Comparison checkpoint is used to compare two web pages. 1.. Copyright © 2009 AutomatedQA Corp.Web Page Testing 197 17.image element. The index will be either the ID or Name attribute. 17. . If the element does not have either attribute. To access the Web Comparison checkpoint. · TAG .HTML elements have the same form as DOM but are sorted by type.3 Naming Conventions The naming convention for HTML elements used by TestComplete depends on the web page model used: · DOM .HTML elements have the form ObjectType(Index).2. TestComplete will assign an index number based on the order the item was created.div element..0 Release .

198 TestComplete 7 Made Easy . 2.0 Release .. . Copyright © 2009 AutomatedQA Corp.2..or the checkpoint drop down from on the Editor toolbar of TestComplete. Selecting either option displays the Create Web Comparison Checkpoint dialog.

Only the selected elements will be compared.Only tag names are compared. The dialog has the script code that will perform the web page comparison.2. o Links . Use the target icon to select the web page.Only INPUT elements are compared. o Images . If you do the comparison while recording.Web Page Testing 199 3. · Compare only tab structure . · Compare entire page .Only A elements are compared (text and attributes of the element are compared as well). Press the OK button and you will be presented with the Copy Text to Clipboard dialog. The extent of the comparison is controlled by the options below the "Page object" in the dialog.Read content from the browser's window or the web server 5. o Input elements . attributes' values and elements' values.Only IMG elements are compared. Note: In this case the dialog contents will be placed into the clipboard so you can paste them into your script routine. 4.0 Release . Copyright © 2009 AutomatedQA Corp.The whole HTML page is saved and is compared. not attributes. o Read content from a server . TestComplete puts the code in for you automatically. . · Compare only specified tags .

200 TestComplete 7 Made Easy Tip: If you have a web page that has dynamically created items. 17.. .5 Web Accessibility Checkpoint It is increasingly important to check that your web pages are accessible. 1. Copyright © 2009 AutomatedQA Corp. Use the Web Accessibility Checkpoint to verify accessibility compliance.2. you can set a timeout for the web comparison to wait for the page to be populated before doing the comparison (default is the Autowait timeout)..0 Release . To create a Web Accessbility Checkpoint use either the recording toolbar.

2. .Web Page Testing 201 .. or the Editor toolbar in TestComplete.. Selecting either option will display the Create Web Accessibility Checkpoint dialog. Copyright © 2009 AutomatedQA Corp.0 Release .2.

4. Press the OK button and TestComplete will present you with a dialog showing code for the Web Accessibility Checkpoint. SELECT.Verifies that none of the IMG elements contain SRC attribute with parameters. · Check server-side images . · Check ActiveX objects . whose HREF attribute starts with mailto: · Check image sizes . · Check Applet object . · Check multimedia links . · Check tab indexes . AREA and INPUT elements must have a non-empty ALT attribute.Verifies there are no Applet objects on the web page. · Check link accessibility .202 TestComplete 7 Made Easy 3.0 Release .All IMG elements must have the WIDTH and HEIGHT attributes specified.The web page must have a non-empty TITLE elment.Web page must have at least one A element (link). and TEXTAREA elements must have the TABINDEX attribute. .Verifies there are no ActiveX objects on the web page.Verifies there are not AVI or SWF files on the web page. · Check "mailto:" . · Check "title" tag . Copyright © 2009 AutomatedQA Corp.All IMG.All INPUT.Checks for broken links. APPLET.2. The types of accessibilities that TestComplete can check for are: · Check "alt" attribute .

Find to search for a link with title element "Products": [VBScript] Sub NativeFind Dim PageObj Dim ProductLink Set PageObj = Sys.Exists Then ProductLink. The first parameter is the name of the property you are searching for."A") if ProductLink.Find("title". For example on http://www. The Page object uses NativeWebObject. 17.automatedqa.com/") Set ProductLink = PageObj. The example below uses Sys. The optional last parameter is the Tag type to search for.6 Finding Web Page Elements Since not all web elements have an ID or Name property (or they might have been created dynamically).automatedqa. Find returns the found element or an empty element with the Exists property set to false."Products". Page("http://www. TestComplete provides a couple of ways to find elements by using properties of the element.Process to retrieve the Page object.Web Page Testing 203 .Click End If End Sub Copyright © 2009 AutomatedQA Corp. NativeWebObject.2.com. such as innerText. The first one uses the Page object's NativeWebObject.0 Release . the Products link on the header does not have a name or an id.Find takes three parameters. two required and one optional. The second parameter is the value to search for. such as "A". .NativeWebObject.Find() method.Process("iexplore").

ValuesArray Dim PageObj Dim ProductLink ' Creates arrays of properties and values PropArray = CreateVariantArray(0.Click() } The second method to find objects on a web (or any other application).0 Release .automatedqa. AArray[j]).ValuesArray. To perform the same search as above: [VBScript] Sub TestedObjFind Dim PropArray.RemoveAll().Add(j.OleObject("Scripting.Process("iexplore").Click End If End Sub [JScript] function ConvertArray(AArray) { // Uses the Dictionary object to convert a JScript array var objDict = Sys.2.Find() method. This method allows you to use multiple properties and values to select a web element."Products". is to use the TestedObject.NativeWebObject. not the TestedObject.Find(PropArray. In this case the page object is the TestedObject.automatedqa. 1) ValuesArray = CreateVariantArray(0. . The example below uses the page object again. 1) ' Specifies property names PropArray(0) = "title" PropArray(1) = "tagName" ' Specifies the property values ValuesArray(0) = "Products" ValuesArray(1) = "A" Set PageObj = Sys.Find("title".Items().Process("iexplore").com/") ProductLink = PageObj.Exists) ProductLink. } function TestedObjFind() { Copyright © 2009 AutomatedQA Corp.Page("http://www."A") if (ProductLink. for (var j in AArray) objDict.Dictionary").3) if ProductLink.com/") Set ProductLink = PageObj. objDict.Page("http://www.Exists Then ProductLink. return objDict. TestedObject can be any on-screen object.204 TestComplete 7 Made Easy [JScript] function NativeFind() { var PageObj var ProductLink PageObj = Sys.

For example the web page http://www. var ProductLink.Web Page Testing 205 var PropArray. // Converts arrays ConvertedPropArray = ConvertArray(PropArray). TestComplete will search the object tree three levels below the current selected TestedObject. ConvertedValuesArray = ConvertArray(ValuesArray). 1. ConvertedPropArray.Process("iexplore"). 17. For Vista you must run Internet Explorer with administrator privledges. // Specifies the property values ValuesArray[0] = "Products". Start Internet Explorer 2. Below the page object.3) if (ProductLink. // Specifies property names PropArray[0] = "title".Find(ConvertedPropArray. You can refer to the Hands On Lab for this chapter to set this up. it will depend on the current depth and how far down you need to search. If you are using the page object. If you were to attempt recording interaction with this menu.automatedqa. The depth value indicates that at most. . NativeWebObject. ConvertedValuesArray. PageObj = Sys.Page("http://www.Exists) ProductLink.ConvertedValuesArray. ValuesArray = new Array(2).net/AJAX/AjaxControlToolkit/Samples/HoverMenu/HoverMenu. TestedObject.0 Release . To get the HoverMouse method in the record you can do the following: Note: This example may vary depending on your OS version (Vista or XP) as well as your browser version. var PageObj. only mouse click and keyboard entry. PropArray[1] = "tagName".Click() } Note: Notice that the Find() method passes a depth value of 3. Browse to http://www.Find() provides more flexibility.aspx Copyright © 2009 AutomatedQA Corp.aspx has a hover menu attached to the word "Have project idea". The lack of mouse movement information can present a problem in dealing with dynamic HTML elements such a Hover Menus which require the mouse to hover (move over) the menu to active.net/AJAX/AjaxControlToolkit/Samples/HoverMenu/HoverMenu. // Creates arrays of properties and values PropArray = new Array(2).7 Dynamic HTML Script recording in TestComplete does not record mouse movements. ValuesArray[1] = "A". For more complex searches.asp.2. This can be solved by using the HoverMouse method in the script.com/") ProductLink = PageObj. Choosing the method to use depends on how far down the object tree you are and how complex a search you require. the playback would fail as the menu would not be visible to click on. ValuesArray.Find() is the fastest.asp.

net/AJAX/AjaxControlToolkit/Samples/HoverMenu/HoverMenu.asp.net/AJAX/AjaxControlToolkit/Samples/HoverMenu/HoverMenu.linkCtl00SamplecontentGridview1C.panelCtl00SamplecontentUp1 .ToURL( "http://www. Stop the recording [VBScript .panelMasterContentplaceholder.panel . page.panelMasterPage. Hover the mouse over the first row until the popup menu appears then click the Edit link.panelMasterContentplaceholder.206 TestComplete 7 Made Easy 3.panel.panelMasterContent .iexplore.aspx"). 1.iexplore.panelCtl00SamplecontentUp1. page = Aliases. if we playback this recording it will fail as the popup menu will not be on screen.formAspnetform.panel.ToURL( "http://www.2.aspx") page.panelCtl00SamplecontentGridview11 .pageHovermenuSample Call page.Click(). .asp.panelMasterPage.panelDemoarea.panelCtl00SamplecontentGridview11.cell . page. 4.panelMasterContent . We need to use the HoverMouse method on an object within the first row to allow the popup menu time to appear.tableCtl00SamplecontentGridview1.panel.pageHovermenuSample.cell.Recorded Code] function Test1() { var page.formAspnetform. Use the Object Browser to locate a textnode within the first row of the grid (you can use the Object Properties window and its Finder tool to make this easier) Copyright © 2009 AutomatedQA Corp.Click End Sub [JScript .panel.panelDemoarea.linkCtl00SamplecontentGridview1C.panel . } At this point.Recorded Code] Sub Test2 Dim page Set page = Aliases.0 Release .tableCtl00SamplecontentGridview1.

textnodeCtl00SamplecontentGridvi Call textNode.Modified Code] Sub Test1 Dim page Dim cell Dim textNode Set page = Aliases. . With the information pertaining to this text node we can modify our code to call the HoverMouse method allowing the popup menu to appear on screen. 5) Call cell.panelCtl00SamplecontentUp1 .table.panel.0 Release .asp.2.cell .formAspnetform.tableCtl00SamplecontentGridview1. [VBScript .iexplore.aspx") ' Code to hover the mouse over the text of the first cell of the table Set cell = page.panelMasterContent .panelCtl00SamplecontentGridview11.ToURL( "http://www.Click() End Sub [JScript .panelMasterPage.net/AJAX/AjaxControlToolkit/Samples/HoverMenu/HoverMenu.pageHovermenuSample Call page.Modified Code] function Test2() Copyright © 2009 AutomatedQA Corp.panelDemoarea.panelCtl00SamplecontentGridview1.panel.panelMasterContentplaceholder.linkCtl00SamplecontentGridview1C.Web Page Testing 207 2.cell Set textNode = cell.panel .HoverMouse(5.

HoverMouse(5. textNode. 17.Click().208 TestComplete 7 Made Easy { var page. cell. // Code to hover the mouse over the text of the first cell of the table cell = page.google.iexplore.aspx").panelMasterContentplaceholder. 2.formAspnetform.cell . 4.panelMasterContent . page = Aliases.tableCtl00SamplecontentGridview1.textnodeCtl00SamplecontentGridvi.panel .) next to the application and add "http://www.2.panel .0 Release . and run as administrator see below for an example.asp. page. 3.panelCtl00SamplecontentGridview1.8 Hands on Lab: Work with Web Pages Basic Web Page 1. Click the ellipse button (.ToURL( "http://www.. With Vista. Add Internet Explorer as the tested application.net/AJAX/AjaxControlToolkit/Samples/HoverMenu/HoverMenu.panelMasterPage. Create a new project. var textNode. Note: Your recordings may differ depending on which version of Windows you're using and which version of Internet Explorer you're testing with.panelDemoarea.. Add "Tested Apps" project item to the project. .com/" as the command line parameter. } The code above will now hover the mouse over the first row of the grid allowing the popup menu to appear and thus allowing the click to work.linkCtl00SamplecontentGridview1C.panelCtl00SamplecontentUp1. 5). textNode = cell.table. var cell.panelCtl00SamplecontentGridview11. Copyright © 2009 AutomatedQA Corp.panel.pageHovermenuSample. you need to change the run mode from simple to run as.cell.

Type "Falafel Software" (without the quotes) into the Google Search box 8.0 Release .com/search?hl=en&q=falafel+software&aq=f&oq=&aqi=g1" iexplore.2. Click the Google Search button 9.buttonGoogleSearch.cell. Click the run application button in the recording toolbar to start Internet Explorer 7.iexplore Set page = iexplore.com/") Set form = page. Press the recording button in the test engine toolbar.Click 'Please wait until download completes: "http://www.Run Set iexplore = Aliases. .textboxQ.Web Page Testing 209 5.formF Call form.iexplore.panelGacBt. Sub Test1 Dim iexplore Dim page Dim form TestedApps.pageFalafelSoftwareGoogleSearch.Wait End Sub [Jscript] Copyright © 2009 AutomatedQA Corp.table.ToURL("http://www.tableGacM. Stop the recording (Your code may not exactly match the example below).pageGoogle Call page.cell.google.Keys("falafel software") form.google. 6.

iexplore.cell.Run().iexplore.pageFalafelSoftwareGoogleSearch.210 TestComplete 7 Made Easy function Test1() { var iexplore. Close the Tested Application (IE or Firefox).Click(). Change the last line to below (notice the extra space).NativeWebObject.pageFalafelSoftwareGoogleSearch. Close the Tested Application 11.cell. Run the script. var page. "Falafel Software*". 4. 2.ToURL("http://www. [VBScript] iexplore. Change the code to look like the example below. Using NativeWebObject.formF Copyright © 2009 AutomatedQA Corp. Copy the recording above to a new method.iexplore. [VBScript] Sub FindTest Dim iexplore Dim page Dim form TestedApps. //Please wait until download completes: "http://www. TestedApps.com/") Set form = page.google. form.Find Method 1. iexplore = Aliases.0 Release .pageGoogle Call page. page.formF.google. page = iexplore. "Falafel Software*".panelGacBt.Find( "innerText".Keys("falafel software").buttonGoogleSearch.Click [JScript] iexplore.textboxQ. Using TestComplete's Find Method 1. 2. form.com/"). form = page.pageGoogle. Copy the code from above into a new method.Find( "innerText".Run Set iexplore = Aliases.table. "A").google.NativeWebObject. 3. .2.pageFalafelSoftwareGoogleSearch.com/search?hl=en&q=falafel+software&aq=f&oq=&aqi=g1" iexplore.iexplore Set page = iexplore. var form.tableGacM.Wait().Click().ToURL("http://www. "A"). Run the recorded test. } 10.

// Creates arrays of properties and values PropArray = new Array(2). AArray[j]).textboxQ.google.table.RemoveAll().Items().Wait Dim PropArray. objDict.pageFalafelSoftwareGoogleSearch. // New Stuff below var PropArray. ConvertedValuesArray. ValuesArray ' Creates arrays of properties and values PropArray = CreateVariantArray(0.panelGacBt.buttonGoogleSearch. form. for (var j in AArray) objDict.pageFalafelSoftwareGoogleSearch.2. page.Run().tableGacM.OleObject("Scripting.cell.100).textboxQ.formF.buttonGoogleSearch. Copyright © 2009 AutomatedQA Corp. TestedApps.Refresh iexplore. 1) ' Specifies property names PropArray(0) = "tagName" PropArray(1) = "innerText" ' Specifies the property values ValuesArray(0) = "A" ValuesArray(1) = "Falafel Software*" iexplore. var page.Click(). form.0 Release .google.com/search?hl=en&q=falafel+software&aq=f&oq=&aqi=g1" iexplore.Click 'Please wait until download completes: "http://www.Keys("falafel software"). .pageFalafelSoftwareGoogleSearch. form = page.Wait().Web Page Testing 211 Call form.com/search?hl=en&q=falafel+software&aq=f&oq=&aqi=g1" iexplore.cell.Add(j.pageFalafelSoftwareGoogleSearch. return objDict.iexplore.Click End Sub [JScript] function ConvertArray(AArray) { // Uses the Dictionary object to convert a JScript array var objDict = Sys. page = iexplore.google.com/").table. iexplore = Aliases. //Please wait until download completes: "http://www. 1) ValuesArray = CreateVariantArray(0. ValuesArray. // Specifies property names PropArray[0] = "tagName". ConvertedPropArray. } function FindTest() { var iexplore.ValuesArray. var form.cell.cell.Keys("falafel software") form.panelGacBt.tableGacM.Dictionary").iexplore.Find(PropArray.pageGoogle. ValuesArray = new Array(2).ToURL("http://www.

ConvertedValuesArray. Close the Tested Application 17. } 3.Find(ConvertedPropArray.pageFalafelSoftwareGoogleSearch . we learned about the different types of web checkpoints TestComplete has. 4. iexplore.Refresh(). . The Find methods made it easier for us to deal with unnamed web elements and the HoverMouse method made it so we could test dynamic HTML elements.0 Release .100). ValuesArray[1] = "Falafel Software*". ConvertedValuesArray = ConvertArray(ValuesArray). // Converts arrays ConvertedPropArray = ConvertArray(PropArray). Run the script. iexplore. Copyright © 2009 AutomatedQA Corp.212 TestComplete 7 Made Easy PropArray[1] = "innerText".2. In addition. how TestComplete represents web pages in the Object Browser and how to switch between them.Click().pageFalafelSoftwareGoogleSearch.9 Summary In this section we learned about web page testing. // Specifies the property values ValuesArray[0] = "A". and how to use them.

Part XVIII WebServices Testing .

b. Select the WSDL file for the web service. c. Copyright © 2009 AutomatedQA Corp. Using the Web services project item. 18. Select the Web services project item 2. Importing Web Service Information into TestComplete In order to use a Web service in TestComplete: 1. · Creating Web Service Types (objects) in TestComplete. web service methods and parameters.214 TestComplete 7 Made Easy 18 18. In this section you'll learn: · Importing Web Services into TestComplete. a. Enter the URL (location) into the web service.2. · Calling Simple Methods of Web Services in TestComplete. b.1 WebServices Testing Objectives This section demonstrates how to test a web service. select Add | New Item… from the context menu.2 Testing against WSDL TestComplete uses a WSDL (Web Service Definition Language) file to discover information about Web services. Name the Web Service project Item (SimpleProjectTracker) and click the OK button. Add the Web services project item to your project (a place holder for all the child Web Service Project Items) a. Add a Web Service project item to the Web services Project Item.0 Release . Click the Get Services button. 3. . The Web services project item is used to perform functional testing of web services. · Calling Complex Method of Web Services. Right-Click the newly added Web services project item and select Add | New Item… from the context menu. · Creating a Web Service Checkpoint. b. you can perform the following actions: · Explore methods and objects used by the tested Web service. · Create script code that will call the service’s methods. d. Right-Click on the project. Select the Web Service to test from the drop down list. Click the Select button for the Web Service Definition URL. a. · Check the service response to determine if the methods function properly.

2. Copyright © 2009 AutomatedQA Corp.WebServices Testing 215 e. .0 Release . Click the OK button A list of types and methods that are available for the selected Web service is displayed.

216 TestComplete 7 Made Easy Working with the Web Service: Simple Methods Our definition of a “simple” method is one that takes primitive data values (string.Message(WebServices. Boolean) as parameters and returns a primitive data value. [VBScript] Call Log.0 Release . For example.HelloWorld()).SimpleProjectTracker.SimpleProjectTracker. . numbers.2.HelloWorld) Copyright © 2009 AutomatedQA Corp. inside of a method of the project enter: [JScript] Log.Message(WebServices.

WebServices Testing 217 Using the TestComplete AutoCompletion feature you can import the example Web Service supplied with the book.TypeFactory. Luckily. To access the code generator: 1.SimpleProjectTracker. Move the cursor between the parenthesis. 3. Expand the list of types in your web service. an object to hold the data will need to be created. 2. var TypeFactory. Type “.SimpleProjectTracker. Copyright © 2009 AutomatedQA Corp. Click the “Code” button at the end of the line with the type.User End Function This code creates the User object for use with the Web Service (such as invoking the AddNewUser method). 2. //Get the type factory for the web service TypeFactory = WebServices. Type “W[Enter].User. [JScript] function User() { var Result. The previous example above can be generated using AutoCompletion: 1. TestComplete has a code generator to make the creation of the object easy. return Result. Select the type desired. Select the “HelloWorld” method from the code completion. 7. } [VBScript] Function User Dim TypeFactory 'Get the type factory for the web service Set TypeFactory = WebServices.TypeFactory Set User = TypeFactory.2. Result = TypeFactory. 6.0 Release . 3.m” in the code editor. 4. The following code sample demonstrates creating a user data element as generated by TestComplete. . Select the Web Service from the code completion (MyWebServiceName).” 5. Press the "[Enter]" key.”. Working with the Web service: Complex Methods In order to send a complex data element to a web service. Type “Log.

Paste the generated code into the script editor using either "<ctrl>-V" or the Edit | Paste menu option.0 Release .218 TestComplete 7 Made Easy 4.SimpleProjectTracker. we can use this method to add a new user to the database using the Web service. The method we are calling in the Web service is AddNewUser(). [JScript] function AddAUser() { var aUser. aUser.2.com". aUser.Name = "Test".Message("New User Id is " + WebServices. 5. Log. Copy the generated code to the clipboard.Email = "test@test. aUser = User(). . Now that we have the method to create a User.AddNewUser(aUser)). } Copyright © 2009 AutomatedQA Corp.

SimpleProjectTracker. performing the operations by hand is more flexible. select the Create Web Service Checkpoint from the Tools toolbar.Name = "Test" aUser.3 WebServices Checkpoint You can perform all of the operations needed to call a web service’s method and check the results yourself.WebServices Testing 219 [VBScript] Sub AddAUser Dim aUser Set aUser = User() aUser. In general. right-click somewhere in the toolbar area and select Tools from the ensuing context menu: Copyright © 2009 AutomatedQA Corp. . select toolbar: Create Web Service Checkpoint from the Recording To display the wizard at design time.com" Log.0 Release .Message("New User Id is " & WebServices. · Generate script code that calls the web service’s method and checks the result. which is important if you are new to TestComplete. If this toolbar is hidden.Email = "test@test. but the wizard helps you create the checkpoints faster and more conveniently. The wizard helps you perform the following actions: · Create an XMLCheckpoint project item that stores a baseline copy of a web service’s response.AddNewUser(aUser)) End Sub 18. You can invoke the wizard when recording a test or at design time: To display the wizard when recording a test. or you can use the Create Web Service Checkpoint Wizard to walk you through the process.2.

Copyright © 2009 AutomatedQA Corp.220 TestComplete 7 Made Easy In the wizard. · Specifying the method parameters. choose the web service method to be called. 2.0 Release . · Selecting the method to be called. · Specifying the expected result. Invoke the wizard. On the "Select Web Service Method" page of the wizard.2. On the "Select Web Service" page of the wizard. select the Web Service project item that corresponds to the tested web service. . the following actions will take place: · Selecting the desired web service. 1.

invoke the special "Complex Parameter" dialog. Note: To specify complex parameter values (that refer to objects).2. Copyright © 2009 AutomatedQA Corp. Boolean and so on). enter the method parameter values. enter its value directly on the page. On the "Specify Method Parameters" page.0 Release . . If the parameters have a simple value type (a string. integer.WebServices Testing 221 3.

specify the XMLCheckpoint project item that will store the expected response of the web service method. On the "Store Expected Response" page of the wizard. .0 Release . Copyright © 2009 AutomatedQA Corp.2.222 TestComplete 7 Made Easy 4.

0 Release . You should replace this pre-defined value with the expected value. 5. TestComplete automatically creates (or updates) the specified XMLCheckpoint project item and then generates script code that calls the method and compares the result with the data stored by the project item. For instance. if the method returns an integer value. enter a string that starts with a letter and that only contains letters. Else. TestComplete automatically generates the expected response of a method call. When creating a new project item. remember that TestComplete will use the project item’s name to address this project item from scripts. Press "Finish" to close the wizard. By default. then TestComplete generates the 0 value for the element that holds the result value. TestComplete uses predefined values for XML document elements that correspond to the result value (or values). Copyright © 2009 AutomatedQA Corp. the name must be a valid script identifier. To specify a name that will conform to the rules of any language. So. digits and underscore symbols. the comparison will be meaningless.2. Scripting languages supported by TestComplete use different naming rules. .WebServices Testing 223 The response can be saved to a new or to an existing XMLCheckpoint project item.

Error("The AddNewProject method of the SimpleProjectTracker web" _ " service returned an incorrect value.224 TestComplete 7 Made Easy Part of the Project Explorer w ith a Web Services checkpoint If the checkpoint was created during recording. 18.AddNewProject(XML.SimpleProjectTracker)) Log.AddNewProject.SimpleProjectTracker)) Then Call Log."). Copyright © 2009 AutomatedQA Corp. [VBScript] Call WebServices. Here.AddNewProject.project).SimpleProjectTracker. TestComplete has settings to ensure that the test will complete even if one of the computers involved gets disconnected.project) If (Not XML. If the checkpoint was created at design time. TestComplete displays the Copy Text to Clipboard dialog.Compare(WebServices. the generated code can be copied to the clipboard and then pasted into the script code.SimpleProjectTracker. TestComplete displays the generated code in the Add Text to Script dialog.4 WebServices Testing Dialogs The testing of web services can occur across multiple computers. .0 Release .Error("The AddNewProject method of the SimpleProjectTracker web" + " service returned an incorrect value. Using this dialog you can insert the generated script instructions into the recorded code.Compare(WebServices. if(!XML. Using the "Web Services Options" dialog. you can configure the HTTP Proxy settings as well as the timeout values used to close inactive connection.AddNewProject(XML. TestComplete will throw an exception if a timeout occurs.") End If [JScript] WebServices.2.

You can obtain proxy connection information from your IT department. Timeout Settings: The timeout settings are used by TestComplete to close inactive connections to the web service.WebServices Testing 225 Web Services Options Settings Proxy Settings: Select the "Use HTTP Proxy" checkbox if your computer requires a proxy server to connect to the web service. TestComplete treats the connection as inactive and raises an exception. TestComplete treats the connection as inactive and raises an exception. if the request takes longer than the "Send" timeout. Copyright © 2009 AutomatedQA Corp. TestComplete waits for a response. If the web service does not respond in the time specified by the "Connect" timeout.2. The timeout logic works with the connect. · After sending the request. TestComplete will treat the connection as inactive and raises an exception. receive and send timeout settings in the following order: · TestComplete will first make a connection request to the web service.0 Release . if this takes longer than the "Receive" timeout. . · TestComplete then sends the request to the web service.

TestComplete will report the differences.5 XML Checkpoint The XML checkpoint is used to compare two different XML documents (such as the response from a Web Service method call).2. The following steps are performed for each node: · Finds the "matching" node from each document and compares each of the node values. . Copyright © 2009 AutomatedQA Corp. · Compares node attributes and namespace declarations. Nodes are matched on the baseName. · Gets a list of child nodes and performs a comparison. TestComplete compares two XML documents by moving down the hierarchy of document elements and comparing each document node.226 TestComplete 7 Made Easy 18. namespaceURI properties as well as node prefix and type. If the node or any of the child nodes are different. TestComplete stores the XML checkpoint information under the "Stores | XML " project item folder. The comparison starts at the root node for each document.0 Release .

0 Release .WebServices Testing 227 By configuring the checkpoint options of an XML checkpoint. the default behavior of the comparison can be changed.2.TestComplete does not check if the node was found in the same place in both Copyright © 2009 AutomatedQA Corp. . The checkpoint options are: · Ignore node order .

2. Name the Web service “TrainingWS”. Calling a Simple Web Service Method 1. 18.TestComplete does not check the namespace attribute of the XML nodes. enter the following URL: <supplied. 3.6 Hands on Lab: Testing a SOAP 1. Right-click the "Web Services" project item and select Add | New Item…. · Create a Web service checkpoint. 2. Add the "Web Services" project Item to the project. · Ignore prefixes . we will: · Call a simple Web service method. · Ignore attributes . · Ignore namespace declarations . 5. · Create a Web service type (object) and use the object for calling a method.instructor>/SimpleProjectTracker/SimpleProjectTrackerWebService.228 TestComplete 7 Made Easy documents.TestComplete only compares names and values for the XML elements. Create a new project in TestComplete.asmx?WSDL If IIS is not installed.0 Release . 6.TestComplete does not check the prefix on the name of the XML node. enter the URL: http://localhost/SimpleProjectTracker/SimpleProjectTrackerWebService. If you have IIS installed on your computer. · Compare in subtree mode . .asmx?WSDL Copyright © 2009 AutomatedQA Corp.2 Web Service In this lab.by. Click the Select button in the “TrainingWS” workspace editor.The comparison results will not include nodes that only exist in the actual document and not in the stored (expected) document (Good for checking only part of an XML document). 4.

2.Name) End Sub [JScript] function GetTask() { var ReturnValue. Log. Copyright © 2009 AutomatedQA Corp. Right-click inside the method just created and select Run Current Routine.Name" [VBScript] Sub GetTask Dim ReturnValue Set ReturnValue = WebServices.TrainingWS. Add a line to Log the value of "ReturnValue. 8.GetTaskByID(1). Create a variable for your scripting language.Message("Task 1 is " & ReturnValue.GetTaskByID(1) Log.WebServices Testing 229 7. 13.TrainingWS. ReturnValue = WebServices. Click the "Get Services" button.0 Release . 9. Assign the value to the results of " WebServices.Message("Task 1 is " + ReturnValue. Call the variable "ReturnValue". Call the method "GetTask". Create a new method in the script editor. Select the SimpleProjectTrackerWS (SOAP 1. 12.Name). . Click the "OK" button.TrainingWS.GetTaskByID(1) ".2) as the tested service. 11. Caution: This result is actually a complex value (object) so be careful with the assignment (use SET for VBScript). 10. } 14.

In the project created above. Call the variable "ReturnValue". In VBScript the Set Project = TypeFactory. Create another variable. Set the value of "Prj" to the results of the “ProjectType” method. 13.TrainingWS. Assign the value of 1 to the “Manager” property of the “Prj” Object. 14. Note: Project is a keyword in TestComplete.Project needs to be changed to Set ProjectType = TypeFactory. 8. 10. Assign the value of Utilities. select the Web Service Workspace editor for the TrainingWS (the tab named TrainingWS or double click the TrainingWS project Item). Object. . Move to the script editor and paste the code in the editor. Click the Code button in the editor. 7. 3. 15.Project End Function Sub AddProject Dim Prj Copyright © 2009 AutomatedQA Corp. 4. Log the result: [VBScript] Function ProjectType Dim TypeFactory 'Get the type factory for the web service Set TypeFactory = WebServices. 6. Expand the Types in the Objects and Methods section of the editor.TrainingWS.TypeFactory Set ProjectType = TypeFactory. 2. Click the Copy button in the Generated Code dialog.Project. 9. Assign the result of the "WebServices. Select the “Project” Type.AddNewProject using the "Prj" variable as the input parameter to the web service method call to "ReturnValue" 16. Rename the function from "Project" to "ProjectType".Date()+7 to the "DueDate" property of the "Prj" Object.0 Release . Assign the value of “TestComplete Training Lab” to the “Name” property of the “Prj”. 12.2. 11. 5. Add a variable to the method called “Prj”.230 TestComplete 7 Made Easy Create a Web Service Type and Call a Method 1. Create a new method in the editor called “ AddProject”.

2. return Result.Name = "TestComplete Training Lab" Prj.WebServices Testing 231 Set Prj = ProjectType Prj.Name = "TestComplete Training Lab" Prj.Project. } 17. 3. var TypeFactory.2.AddNewProject(Prj) Log. 4.DueDate = Date() + 7 Dim ReturnValue ReturnValue = WebServices. Click the Web services checkpoint button ( ) in the Tools toolbar. var ReturnValue. Select the TrainingWS Web Service and click the Next button.TrainingWS. Log. Right Click inside the method just created and select "Run Current Routine" Creating a Web Service Checkpoint 1. Prj.TypeFactory. Select the “GetProjectByID” method from the list.Message("New Project Id is " + ReturnValue). Copyright © 2009 AutomatedQA Corp.Date() + 7.DueDate = Utilities.Manager = 1. Set the 'id' parameter value to 1 and click the Next button. Set the values on the node to match the values shown in the image below inside the soap:Body area only. . Prj = ProjectType(). Result = TypeFactory. Prj.0 Release .AddNewProject(Prj).Message("New Project Id is " & ReturnValue) End Sub [JScript] function ProjectType() { var Result.Manager = 1 Prj. ReturnValue = WebServices. 5.TrainingWS.TrainingWS. } function AddProject() { var Prj. //Get the type factory for the web service TypeFactory = WebServices.

2. 7. .0 Release . Click the Finish button. 8. Copyright © 2009 AutomatedQA Corp. Create a new method in the script edited called "Checkpoint1". Click the Copy button of the Copy Text to Clipboard dialog.232 TestComplete 7 Made Easy 6.

Copyright © 2009 AutomatedQA Corp.TrainingWS)) Then Call Log.Error( "The GetProjectByID method of the TrainingWS web service returned an incorrect"+ "value.TrainingWS.GetProjectByID.WebServices Testing 233 9. Paste the copied code into the routine.0 Release .") End If End Sub [JScript] function CheckPoint1() { WebServices.TrainingWS. } 10. if(!XML. An error message is displayed in the test log. 11.GetProjectByID. Right click in the routine and select Run Current Routine.GetProjectByID(1) If (Not XML.Compare(WebServices.Compare(WebServices. [VBScript] Sub CheckPoint1 Call WebServices.GetProjectByID(1). Expand the details of the XML node in the test log to see the errors. .").TrainingWS)) Log.Error(_ "The GetProjectByID method of the TrainingWS web service returned an"_ " incorrect value.2.

No error will be displayed in the test log. Delete the Description and DueDate nodes. 14. 13. Re-run the "Checkpoint1" Routine. 15. Copyright © 2009 AutomatedQA Corp. Double-click the "GetProjectByID" project item of the "Stores | XML" project item.234 TestComplete 7 Made Easy 12. Expand the nodes until the Description and DueDate nodes are shown.0 Release . Check the "Compare in subtree mode" 16. .2.

We also learned how to change the default behavior of TestComplete for timeouts and about XML checkpoints. Copyright © 2009 AutomatedQA Corp.7 Summary In the section we learned how to retrieve information about web services in order to perform web service testing. . We started by testing with a simple web service method using primitive types and worked up to testing a web service with a complex interface.WebServices Testing 235 18.0 Release .2.

Part XIX HTTP Performance Testing .

load.2 Performance Testing Your Web Applications Performance testing of a web application is an important part of the development process. In this section you will learn: · What is HTTP performance testing? · The different types of HTTP performance testing · How TestComplete records HTTP traffic · How to modify the HTTP traffic 19. You will also learn about HTTP traffic recording and modification. It will let you know if your application is multi-user friendly and at what point does the application "break-down". Select Tools | Options from TestComplete main menu. scalability). Select Engines | HTTP Load Testing from the options tree on the left of the dialog.g.0 Release . stress. 2.2.HTTP Performance Testing 237 19 19. . 19. Note: TestComplete can record traffic against HTTP as well as HTTPS connections. The default HTTP Load Testing options will display: Copyright © 2009 AutomatedQA Corp. Some of the things that TestComplete can show through analysis are: · Scalability Testing: Do hardware changes to the web server cause change to the performance of the web application? · Load Testing: Do the server's change with different number of users? · Stress Testing: Will enough users cause the web server to crash? · Load Testing or Stress Testing: At what number of users does the web server break or slow down too much? By recording different HTTP tasks.3 HTTP Load Testing Options 1. you can create realistic scenarios of user interaction with the web site.1 HTTP Performance Testing Objectives This section explores HTTP performance testing and other types of performance testing (e.

The number of seconds that TestComplete will wait for a acknowledgement from the web server that a connection has been made. · Simulate request to third-party site .0 Release . TestComplete will only store the header information and not the details of a web request. · Receive times . .The number of seconds that TestComplete will wait for a reply from the web server. Copyright © 2009 AutomatedQA Corp. See the cookie handling section below for more information.If unchecked. Traffic Transponder · Cookie handling . TestComplete will not ask for images or other information from other sites that the web page might request. · Store request details .2.If checked.238 TestComplete 7 Made Easy TestComplete can record both HTTP and HTTPS web traffic and automatically captures these protocols without any specific proxy setting requirements. · Send timeout .Configures how TestComplete handles sending of cookies during playback.

TestComplete will ignore all cookies while running the load test. .This is the same as disabling cookies in your Internet browser. One difference . TestComplete populates the list with common ASP. i. The type of cookies that a web site generates makes a difference in how a web server responds to a request.e. such as a user security token used to authorize an request to a secured web site. The default for a visually created test is to set the ClearCookies property of the virtual users to true. However. Simply right click and select "Edit" (see Hidden Controls editor below). Requests can get out of order if network traffic is high.4 Cookie Handling A cookie is data stored on the client side. 19.The default selection. HTML Hidden Controls Certain web pages. When the ClearCookies property is true. get the web page before the images on the page.NET (using viewstate).1 in the web browser before recording. Tip: If you are planning to modify the recorded HTTP traffic and using 'classic' ASP. turn off HTTP 1.NET. If you want cookies to be recreated.Cookies will affect the server response and the server should produce the same responses as recorded. Firefox.0 Release . since cookies can have expiration dates. 19. TestComplete allows you to specify which hidden values should be updated during playback to better simulate interaction with the server. on the web page you want to start on. By default.Forces the order of requests to remain the same as when recording. This will prevent the web server Copyright © 2009 AutomatedQA Corp. · Use real-time cookies .it is easier if you have your client application (Internet Explorer. utilize hidden HTML controls to transfer information from server to client and back. etc) started. Note: It is also a good idea to clear the cache of the web browser you are using before recording. all cookies are automatically recreated.NET hidden field names though you can add any values necessary for your testing requirements.2. TestComplete will replace the cookies as needed from the web server responses. cookies need to be cleared before starting a load test for virtual users created in script. · Use recorded cookies . like ASP. the response may be an error. Cookie data can change from run to run of a load test and TestComplete allows different methods for handling cookies: · Do not use cookies . and in the case of web browsers. You can specify which controls TestComplete should update during playback by editing the HTTP Load Testing Project Item.5 Recording Recording HTTP traffic is similar to standard recording.HTTP Performance Testing 239 · Synchronize requests .

This will add the http traffic to an existing task. Start by clicking the record button in TestComplete. 2. 1. click the "Record an HTTP task" button. On the recording toolbar.240 TestComplete 7 Made Easy from using HTTP compression. but makes it easier to modify the traffic.CreateVirtualUser("VirtualUser1") Set VirtualUser.0 Release . To select a load testing task either: Enter a name under Record a new task for a new task. 3. Select Append traffic to the following task and select an existing task. .2.HTTPTaskByName("Task") Set VirtualUser = LoadTesting. When the recording is done.Run("Task") End Sub Copyright © 2009 AutomatedQA Corp. you will end up with a script for running a load test with one single virtual user.Task = HTTPTask Call VirtualUser. [VBScript] Sub Test1 Dim HTTPTask Dim VirtualUser Set HTTPTask = LoadTesting.

HTTPTask = LoadTesting. Requests and Responses A load testing task in TestComplete will consist of one or more connections to the web server. Double-click on the Task to get a look at the recorded HTTP traffic.HTTPTaskByName("Task"). VirtualUser = LoadTesting.2.CreateVirtualUser("VirtualUser1"). VirtualUser. } 4.HTTP Performance Testing 241 [JScript] function Test1() { var HTTPTask. VirtualUser. The recorded task will be under the Tasks project item under the LoadTesting project item in the Project Explorer. Copyright © 2009 AutomatedQA Corp.Task = HTTPTask. 19.Run("Task"). Within these connections are requests that TestComplete sends and the recorded or expected response that TestComplete receives. .6 Connections. 5.0 Release . var VirtualUser.

the information can be edited here or changed in script code.7 Visual Creation of a Load Test Load Tests can be created both visually and in script. To create a load test visually: Copyright © 2009 AutomatedQA Corp.2. OnLoadTestingRequest will allow modification of the request before sending it to the web server. The fields of the request header are shown in the table. All of these fields can be modified directly or in script code. etc. an image request will show the image.242 TestComplete 7 Made Easy The request page holds the properties of the currently selected request in the Connections tree. . Again. 19. The "Raise Events" option is used to indicate this request will trigger an OnLoadTestingRequest event during playback. The request method (POST or GET) is shown in the edit box above the fields (note: the protocol version is also shown). a SOAP request will show the SOAP response. For example. Depending on the Content-Type. TestComplete will show the response content below the properties grid. The "Raise Events" checkmark will call the OnLoadTestingResponse for the selected request/response pair.0 Release . The response page shows the properties and contents of the response from the web server for the selected request.

Right-click and select Add | New Item. 7. Enter a "Description" for the test 5. . 6.HTTP Performance Testing 243 1. Select the "Tests" project item under the Load Testing project item 2. 4. Enter or select a "Result Group". Enter a name for the group of users Copyright © 2009 AutomatedQA Corp.. Right-click in the Virtual Users area and select New Item. 3..0 Release . Result groups are used to categorize groups of test runs for analysis. Name the Test.2.

the red line show the total time to perform all requests. Assign the group to run on a particular computer (Master is the local computer). 9. you can run the test by right clicking and selecting Run. The middle section shows how each of the connections did for the currently selected user from the users section. 19. · Did the user complete the task without error/warnings.0 Release . Choose which task this group of user is going to perform. 13. . Enter the number of virtual user you want for this group (it is not recommend that more the 300 virtual users be assigned to a computer). Change the connection speed to simulate the speed of the download. Column heading are: · State (did this connection pass or fail).244 TestComplete 7 Made Easy 8. · The total time needed to complete the task. · The number of connections simulated in the task.8 Analysis of the Test Log The load test log is broken up into parts. · Which station performed the task. Choose which browser to simulate in the request. The start delay is how long after the test starts to kick off this group (simulating a gradual increase in load). The column headings are as follows: · Virtual User # in the order they complete their task. 10. · The task performed. 11. The green line in the graph shows the actual request execution sum. Once you are finished creating the test.2. 12. Copyright © 2009 AutomatedQA Corp. The top part shows how each virtual user did overall. · Virtual User Name.

. · Number of requests in this connect. Copyright © 2009 AutomatedQA Corp. · The time to do the request. · The total time to simulate this connection. · How many bytes per a second where sent/received. · How long it took to do the request. · # of bytes sent/received per a second.2. · How long after the start of the load test was this request sent. · The State of the request. · # of bytes sent per second. Requests and Headers: Requests columns are: · Request # in the selected connection. · Total Bytes sent to the web server for this connection. · # of bytes received. The Headers area shows the actual headers sent and received for the selected request. · # of bytes sent. · how long until a response. · How long it took to Initialize the connection. · The minimum response time for all the requests in this connection · The maximum response time for all the requests in this connection The bottom section is divided into two parts. · Total Bytes received from the web server for this connection. · # of bytes received per a second.HTTP Performance Testing 245 · Host that the connection was run against.0 Release . · The time of day the connection was started. · Which port the connection used.

2. 19.246 TestComplete 7 Made Easy Comparing Multiple Test Runs There is another type of log created that allows comparisons of multiple test runs. you may want to change the properties of the HTTP request and modify it directly before running the HTTP task. Found in the project explorer under the project suite name and ending with the word "Analysis" Select the named group you are interested in and you will get the results of all the test runs for that group.9 Modifying HTTP Traffic With TestComplete you can modify HTTP traffic as necessary.0 Release . [VBScript] Sub Test1 Dim HTTPTask Dim Request Dim VirtualUser Set HTTPTask = LoadTesting. .HTTPTaskByName("Order") Copyright © 2009 AutomatedQA Corp. For example.

random()) + 1 VirtualUser = LoadTesting. since you are making a copy of the HTTP task for each virtual user.Item("albums") = Math.Run("Order") End Sub [JScript] function Test1() { var HTTPTask var Request var VirtualUser HTTPTask = LoadTesting. The Second method is to use the OnLoadTestingRequest event to modify the traffic.random()) + 1 Request.Run("Order") } Caution: There is one warning with this method.random()) + 1 Request.HTTPTaskByName("Order") Request = HTTPTask. . first checkmark the raise events on all the request you wish to modify.Request(0) Request.Item("paints") = Int(1000 * Rnd()) + 1 Request.CreateVirtualUser("VirtualUser1") Set VirtualUser.Item("albums") = Int(1000 * Rnd()) + 1 Set VirtualUser = LoadTesting.Variables.Variables.Variables.Item("pencils") = Int(1000 * Rnd()) + 1 Request. it is possible to consume too much memory causing a slow down of the test.round(100 * Math.0 Release .round(100 * Math.Item("pencils") = Math.Request(0) Randomize Request. You can also configure events to be raised in code: [VBScript] Sub Test1 Dim HTTPTask Dim VirtualUser Copyright © 2009 AutomatedQA Corp. To use OnLoadTestingRequest.Variables.Item("paints") = Math.Variables.2.CreateVirtualUser("VirtualUser1") VirtualUser.HTTP Performance Testing 247 Set Request = HTTPTask.Task = HTTPTask VirtualUser.round(100 * Math.Variables.Task = HTTPTask Call VirtualUser.Connection(0).Connection(0).

Click OK in the New Routine Dialog and add script code to modify the request: [VBScript] Sub GeneralEvents_OnLoadTestingRequest(Sender.random()) + 1 Request.RequestEventTrigger = true VirtualUser = LoadTesting.2.Connection(0).Request(0).10 Hands on Lab: Working with HTTP Traffic Basic HTTP Recording and Playback 1.248 TestComplete 7 Made Easy Set HTTPTask = LoadTesting. Create a new project and project suite using HTTP load testing template.Variables. User.Connection(0).CreateVirtualUser("VirtualUser1").Item("albums") = Math. Copyright © 2009 AutomatedQA Corp.round(100 * Math.0 Release .Variables.round(100 * Math.round(100 * Math.RequestEventTrigger = True Set VirtualUser = LoadTesting.Item("paints") = Int(1000 * Rnd()) + 1 Request.Task = HTTPTask. VirtualUser.HTTPTaskByName("Order") HTTPTask.Request(0).Variables. Request) { Request.random()) + 1 } 19.CreateVirtualUser("VirtualUser1") Set VirtualUser.Run("Task") End Sub [JScript] function Test4() { var HTTPTask. VirtualUser. add the OnLoadTestingRequest event handler. . Open the editor for Events from the Project Explorer and click the New button next to the OnLoadTestingRequest in the HTTP LoadTesting Events category.random()) + 1 Request. User.Variables.Item("paints") = Math.Item("pencils") = Int(1000 * Rnd()) + 1 Request.Item("albums") = Int(1000 * Rnd()) + 1 End Sub [JScript] function GeneralEvents_OnLoadTestingRequest(Sender.HTTPTaskByName("Task") HTTPTask.Variables.Variables.Run("Task"). Request) Request. var VirtualUser HTTPTask = LoadTesting.Task = HTTPTask Call VirtualUser. } Next.Item("pencils") = Math.

· Click the ‘Contact Us’ link.HTTP Performance Testing 249 2. Start up Internet Explorer and open the www. · Stop the recording. Switch from recording a script to recording HTTP traffic. · Click the ‘Home’ link.automatedqa. 5. · Enter ‘TestComplete in the search and hit the Enter key.2. . 4. delete connections that do not point to www.0 Release . 6.automatedqa. Double-click the newly created Task in the Project Explorer.com: Copyright © 2009 AutomatedQA Corp.com web page. 3. In the task editor. Record an HTTP Load Test.

Examine the newly created test log. Modify Traffic Using the OnLoadTestingRequest Event. 8.. Right-click on the Tests Project Item of the LoadTesting Project Item in the Project Explorer and Select Add | New Item.0 Release . . In the HTTP Task select the first request and check mark Raise Events. Create an HTTP Load Test with five virtual users. In the Events Editor. Copyright © 2009 AutomatedQA Corp. · Set the workstation to "Master" 10. 2. Press OK in the Create Project Item Dialog. · Add a description "HTTP Lab" · Add a Result Group "HTTP Lab" · Make sure that "Run concurrently" is check marked. 1. · Right-click the white area under virtual users and select New Item from the context menu..2. · Change the User Count to 5 · Set the Task to the name of new created task. 11. 9. Right-click the newly created Test and select Run from the context menu.250 TestComplete 7 Made Easy 7. select OnLoadTestingRequest and click the New button.

HTTP Performance Testing 251 3. Request) Request. We have learned how to record HTTP traffic and how to modify the traffic before sending request to the web server. Add the following code: [VBScript] Dim SearchValues SearchValues = Array("TestComplete".random())]) } 5. 6.Item("search") = Escape(SearchValues(Int(3 * Rnd()))) End Sub [Jscript] var SearchValues = new Array("TestComplete". Request) { Request. .0 Release . Copyright © 2009 AutomatedQA Corp. we have learned about HTTP Performance testing and the types of performance testing such as load.2.Item("search") = escape(SearchValues[Math. Click the OK button in the New Routine dialog. User."AQtime"."Automated Build Studio"). User. 19. 4.11 Summary In this section. stress and scalability.Variables.Variables. Examine the Headers for the different user to see the changes in the traffic. function GeneralEvents_OnLoadTestingRequest(Sender.round(3 * Math."AQtime"."Automated Build Studio") Randomize Sub GeneralEvents_OnLoadTestingRequest(Sender. Right-click on the Test created from the first part of the lab and select Run from the context menu.

Part XX Remote Agent .

1 Remote Agent Objectives Remote Agent is a tool that allows for the distribution of HTTP loads tests across a network of computers. you will be prompted to select which mode you want Remote Agent to use: 20. Remote agent is launched automatically when Windows starts. console mode which runs on your Windows Desktop or as a Windows service.2. Remote Agent can be installed in two modes. standalone installation of Remote Agent allowing for easy deployment to other machines on a network. In both cases.Remote Agent 253 20 20. Console Mode When running Remote Agent in console mode you'll see this window on your Windows Desktop: Copyright © 2009 AutomatedQA Corp. Remote Agent is started as soon as a user logs onto the machine whereas in service mode. Remote Agent is started when Windows is started regardless of whether or not a user is logged on. In both instances Remote Agent is started when the machine starts though if there is no active user logged onto the machine the Service mode will still be available for use whereas console mode requires a user to be logged onto the machine. . In the case of console mode.0 Release .2 Installing Remote Agent AutomatedQA provides a separate. During installation.3 Running Remote Agent During the installation of Remote Agent you selected a mode indicating how it should be executed either console mode or as a Windows service. In this section you will learn: · Installing Remote Agent · Running Remote Agent · Configuring Remote Agent · Using Remote Agent for HTTP Load Testing 20.

To control the execution of Remote Agent you need to change the settings under Windows Services. . In XP.msc" from the Run command on the Windows Start menu.0 Release . Service Mode When Remote Agent is installed in service mode there is no visible UI that will appear. you can view Windows Services Window by running the command "services.2.254 TestComplete 7 Made Easy To exit Remote Agent from this mode simply activate the window by clicking on it and press Escape. You should see a window that looks like this: Copyright © 2009 AutomatedQA Corp.

0 Release .2. This file is an XML file that can be edited using any plain text file editor such as Windows Notepad. 0-1.config which is created when Remote Agent is executed for the first time.4 Configuring Remote Agent Remote Agent supports several different configuration settings stored in an XML file located in \Program Files\Automated QA\TestComplete 6\RAS\Bin\ras. TestComplete will try to connect to Remote Agent through port 135 as well.3 this setting is obsolete. 20.config XML file: NOTE: In TestComplete 6. Additionally. . Set this option to 1.Remote Agent 255 From this window you can right click on TestComplete 6 HTTP Load Testing Remote Agent and change its Startup Type. Setting ra port description use proxy Description As of TestComplete 6. Any descriptive string concerning the Remote Agent instance on the computer. Below is a table listing the available options that can be configured via the ras.3 and later Remote Agent (RA) is implemented as a Distributed COM (DCOM) server meaning it listens in on the standard Microsoft DCOM port of 135. if -· There is a proxy server between the computer where the Remote Agent and the Copyright © 2009 AutomatedQA Corp.

2. · There is a proxy server between the Remote Agent computer and the computer where TestComplete executes. The XML file appears as follows: <?xml version="1. proxy host Specifies the proxy server that the Remote Agent uses to connect to the tested Web site and to the computer where TestComplete runs. you may set this option to 0. proxy port proxy login proxy password Note: Do not forget to end the RA process (stop its service) before changing its settings and then restarting RA afterwards. Default value: 8080. This can be either the computer name. Default value: 0. Specifies the user name under which you want to connect to the proxy server (if it requires user authentication).256 TestComplete 7 Made Easy tested Web server is installed. or IP address.domain (undefined)"/> Copyright © 2009 AutomatedQA Corp. . Specifies the port which the Remote Agent uses to connect to the proxy server specified by proxy host.0 Release . This option is ignored if the use proxy option is set to 0.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE Nodes [ <!ENTITY % NameValue "CDATA"> <!ENTITY % PropType "(I|S|D|L|H|B)"> <!ENTITY % VersionValue "CDATA"> <!ELEMENT Prp (#PCDATA)> <!ELEMENT Node (Node|Prp)*> <!ELEMENT Nodes (Node)+> <!ATTLIST Nodes version CDATA "1"> <!ATTLIST Node name CDATA #REQUIRED> <!ATTLIST Prp name CDATA #REQUIRED> <!ATTLIST Prp type CDATA #REQUIRED> <!ATTLIST Prp value CDATA #REQUIRED> ]> <Nodes version="1"> <Node name="root"> <Prp name="proxy host" type="S" value="proxy. · If the Remote Agent has direct access to the tested Web site and the TestComplete computer. Specifies the password that confirms the identity of the user under whose name you want to connect to the proxy server (if it requires user authentication). This option is ignored if the use proxy option is set to 0.

0 Release . if any · use proxy . .config 3. To do that you need to edit the above XML file using any plain text editor like Windows Notepad. Creating an HTTP Load Testing Project 1. For example.change the value attribute to the server domain name or IP address of the proxy server · proxy password .Remote Agent 257 <Prp name="description" type="S" value="Workstation's Load Testing service"/> <Prp name="proxy password" type="S" value=""/> <Prp name="use proxy" type="B" value="0"/> <Prp name="proxy port" type="I" value="8080"/> <Prp name="proxy login" type="S" value=""/> <Prp name="ra port" type="I" value="9191"/> </Node> </Nodes> Configuring a Proxy Server If your organization uses a proxy server to connect to the web you'll need to configure Remote Agent to use the proxy server.5 Hands on Lab: Working with Remote Agent for HTTP Load Testing To use Remote Agent you need to setup an HTTP Load Testing project in TestComplete. The Load Testing project has features that allow you to leverage Remote Agent running on multiple machines for testing web applications or services. to configure a proxy server you would: 1.change the value attribute to the password for the proxy server.change the value attribute to the port number used for the proxy 20. Look for the <Prp> with the following Name attributes and change them accordingly: · proxy host .change the value attribute to 1 to enable the proxy · proxy port .2. Start TestComplete and select File|New|Project Copyright © 2009 AutomatedQA Corp. Open \Program Files\Automated QA\TestComplete 6\RAS\Bin\ras. Start Windows Notepad 2.

258 TestComplete 7 Made Easy 2. On the Create New Project dialog select HTTP Load Testing and click OK 3. Click the Finish button on the Project Wizard dialog to create your new project Once created the new project will display the following nodes (based on your TestComplete settings your project may vary slightly): The LoadTesting node contains the items of interest for conducting HTTP Load testing.0 Release .2. These nodes Copyright © 2009 AutomatedQA Corp. .

The easiest way to produce traffic is using TestComplete’s recording facilities. · Tasks .2. Right click the stations node and select Add|New Item. The Master sub-node represents the machine that TestComplete is running on.is the HTTP traffic you’re interested in testing. 2.Remote Agent 259 are: · Stations .. In the Host edit box enter the machine name or IP address. Change the Name edit box to something more meaningful. You will see a dialog that allows you to configure a networked machine that's running Remote Agent.represents the machines that will be conducting the tests.0 Release .allows you to assign tasks to various stations for test execution. Working with Stations In order to leverage Remote Agent running on networked machines you'll need to configure the machines under the Stations node. 3. You can add and remove Stations from your project as necessary from the Project Explorer. · Tests . Setting up Tasks The next step is to create the HTTP traffic you want to load test your server with. . Note: You'll be able to change all of these settings from the project's Workspace so don't worry if you make a mistake.. To add a machine that is running Remote Agent do the following: 1. Copyright © 2009 AutomatedQA Corp.

2. Right-click the Tests node in the Project Explorer and select Add | New Item. Right-click the Virtual Users grid and select New Item.260 TestComplete 7 Made Easy 1. click the Task cell in the grid and select a task from the drop down list. Assigning Tasks to be Executed by Remote Agents Once you've added Stations to your project and created HTTP Tasks for execution you need to configure which Tasks which be executed by which Stations: 1. 4. This will create a new entry in the Virtual Users table and allow you to assign work for a particular Remote Agent. To specify a Workstation (a.k. Copyright © 2009 AutomatedQA Corp. under the Network tab. you're ready to leverage Remote Agent and execute your tests harnessing the power of your networked machines to HTTP Load Test your web applications. This will bring up the Select Load Testing dialog where you can decide to record a new HTTP traffic or append it to an existing task. TestComplete will record the HTTP traffic and add it to the task you specified. Once you click OK you can begin recording HTTP traffic by simply using your browser.0 Release .. Remote Agent) click the Workstation cell and use the dropdown to specify a particular Remote Agent. For IE you can do that from the Connections tab of the Internet Options dialog setting the proxy to localhost on port 9999. To specify a Task to execute.2. Configure Internet explorer to use TestComplete as a proxy allowing it to monitor and record HTTP traffic. 4. 3. For Firefox open the Tools | Options dialog and look on the Advanced page. . Once completed your Virtual Users should appear something like this: At this point. 2.a. On the Create Project Item dialog name the test accordingly and click OK. Click the record button on the TestComplete toolbar and once recording begins click the Record an HTTP Task button (circled in red below): 3.. 5.

Remote Agent has a small footprint and separate install allowing it to be easily deployed for rapid HTTP load testing. With Remote Agent installed a single TestComplete user can quickly and easily harness the power of a network to provide real world load testing of HTTP based web applications.2.6 Summary Remote Agent is a tool that allows for the distribution of HTTP loads tests across a network of computers.0 Release .Remote Agent 261 20. In addition. . Copyright © 2009 AutomatedQA Corp.

Part XXI Distributed Testing .

· How to use SyncPoints. In addition to running the tests. takes place in the master project. the computers involved can communicate with each other using TestComplete. In order to perform a distributed test. all the computers involved must have the same version of TestComplete/ TestExecute on them (including the minor version number). all projects involved must contain the Network Suite project item.This is where you can setup a shared path for all the computers to use in testing. . · How to use Network Suite Variables.2 Network Suites Distributed Testing is the ability of TestComplete to control test cases running on several computers at the same time. Properties . In addition. The root level of Distributed Testing is the Network Suite: The workspace editor for NetworkSuite consists of three parts: 1.Distributed Testing 263 21 21. Most of the setup of a distributed test. The minimum you need to run a distributed test is a master project with at least one host machine and at least one task for that host machine to run.0 Release .1 Distributed Testing Objectives This section explains how tests are run on several computers at the same time. In this section you'll learn: · What is a Distributed Test. · What are the parts of a Distribute Test.2. · How to setup a Distributed Test. TestComplete uses this path to create a network shared folder during the run of the network suite. 21. Copyright © 2009 AutomatedQA Corp.

integer.2. 3. .264 TestComplete 7 Made Easy 2.Using these variables. the computers involved in the test can pass data to each other. This data can only be of types. Variables . Copyright © 2009 AutomatedQA Corp. Run State . double or Boolean.This displays the state of each computer during the test run.0 Release . string.

Hosts need to have either TestComplete or TestExecute on them and can be addressed by either name or IP address.3 Hosts Hosts are the secondary computers involved in the test. Copyright © 2009 AutomatedQA Corp. The base path is where the computer will start looking for the project to run the test (not required). .2.Distributed Testing 265 21. it is recommend that you verify the existence of the host.0 Release . Right-click the workspace to get the context menu and click Verify. Since firewall and other network communication issues can happen.

Each host computer can only be used once in a job for an active task.Whether or not the test is run. Action after run .Controls if the master computer gets a copy of the log file from the host computer.2. 5. Path .4 Jobs/Tasks Jobs and Tasks are where tests to be run are controlled.Path to the TestComplete project that holds the test to be run (relative to the host computer). 2. Copyright © 2009 AutomatedQA Corp. 4.266 TestComplete 7 Made Easy 21.0 Release . Copy the remote log . Active . Under each Job are the Tasks (tests) to be run on the host computer. . Name .Name of the task.Determines the action to take after the test completes on the host computer. Each job is run to completion before the next job is run. A Job consists of one or more host computers tasks. Tasks have the following properties: 1. 3.

Use previous instance . 7. they will continue on with their test.Whether to use TestComplete or TestExecute on the host computer. 21.2. .A value sent to the host computer at the start of the test. When all the computers with a named SynchPoint hit that Synchronize Point. Test . If left blank it will be the project/project suite from the path property. 8. Copyright © 2009 AutomatedQA Corp.The test to be run. 9.Distributed Testing 267 6. Remote application .0 Release .5 SynchPoints SynchPoints delay execution of the test until all computers with that synch point name reach the synchronization point. An example of an effective use for SynchPoints: you want to avoid where two or more users try to edit the same record at the same time and post the data.Controls what to do if TestComplete/TestExecute is already running on the host computer. Tag .

0 Release . "*").Run Set p1 = Sys. Add notepad to the TestedApps project Item of the hosted project.ClickButton End Sub Copyright © 2009 AutomatedQA Corp.Process("notepad") Set w1 = p1.Pos = 0 w1.notepad. 3. 4.6 Setup Simple Distributed Test 1.Keys("TestComplete Training .2. [VBScript] Sub Test1 Dim p1 Dim w1 TestedApps. "*") Call w1.Distributed Testing") w1.Window("Notepad".Window("Notepad".Click(135. 29) Set w1 = p1.Window("Edit") w1. "&No"). "Notepad").Window("#32770".268 TestComplete 7 Made Easy 21. Create a master project with a NetworkSuite Project Item. .VScroll.Close p1. Create (or record) a script method to type something into notepad.Window("Edit"). 2. Create a hosted (slave) project with a NetworkSuite Project Item.Pos = 0 Call w1.Window("Button". Modify the File Path property of the TestedApp to "" (blank) 5.HScroll.

HScroll. 12. 7.Keys("TestComplete Training . "*"). w1 = p1.Process("notepad"). p1 = Sys.Distributed Testing"). Expand the Hosts Project Item and select Host1 9. "&No"). "*").Window("Edit").notepad.Pos = 0.Window("Notepad". "Notepad").2. Enter the name (or IP address) of the hosting (slave) computer. In the Base path property enter "\\<Master Computer Name>\<Name of Project Suite directory>" 11. w1.mds". 8. Select the Task1 Project Item. w1 = p1. Save the project. Select the NetworkSuite Project Item in the Master Project and enter the path to the project suite in the Shared Path.Window("#32770".0 Release . Right-click on Host1 and select Verify from the context menu. 14. 10.VScroll. w1. w1.ClickButton(). 13.Click(135. } 6. 15. .Distributed Testing 269 [JScript] function Test1() { var p1 var w1 TestedApps.Window("Notepad". w1. p1.Run(). Copyright © 2009 AutomatedQA Corp. Expand the Job1 Project Item. w1.Pos = 0.Window("Edit"). In the Path property enter "\<Name of Hosted Project>\<Name of Hosted Project>. 29).Close().Window("Button". Expand the Jobs Project Item.

2.Keys(NetworkSuite.notepad.Pos = 0 Call w1.Var1) w1. 19. Modify the test in the hosted (slave) project. 20. 17.Window("Edit").Window("Edit") w1.0 Release . In the Use previous instance property select "[Use]".Window("#32770".Process("notepad") Set w1 = p1. Right-click Task1 and select Verify from the context menu.Process("notepad").Run Set p1 = Sys.Pos = 0 w1. p1 = Sys.notepad.Window("Notepad".VScroll.Run(). "&No"). Right-click the NetworkSuite project item and select Run from the context menu.Window("Notepad". 1.Close p1.HScroll.Variables. the NetworkSuite is ready to run. Copyright © 2009 AutomatedQA Corp. "Notepad"). "*"). 18.270 TestComplete 7 Made Easy 16. In the Copy remote log property select "[Always]".ClickButton End Sub [JScript] function Test1() { var p1 var w1 TestedApps. 29) Set w1 = p1.Window("Button". Using NetworkSuite Variables NetworkSuite variables allow TestComplete to send data from one computer to another. . [VBScript] Sub Test1 Dim p1 Dim w1 TestedApps. "*") Call w1. With verification. In the Test property enter "<Name of Hosted Project>\Script\Unit1\Test1".Click(135.

29). "*").notepad. "*") Call w1. w1.Window("#32770". .Window("Notepad".Variables. On the host (slave) computer.Window("Edit").Pos = 0. "&No").Keys(NetworkSuite.Variables.Keys(NetworkSuite.Close().Window("Edit").Var1).VScroll.Variables. you will see "TestComplete Rocks" typed into notepad.Window("Notepad".HScroll.Window("#32770". We will show a couple of ways to synchronize.Close p1.ClickButton End Sub Copyright © 2009 AutomatedQA Corp.Process("notepad") Set w1 = p1.Window("Notepad". w1.Pos = 0 w1. p1. you want the consumer's computer to wait until the bank's computer has processed a debit before the consumer's computer checks its balance. Change the Local Value property to "TestComplete Rocks" 4.Window("Edit").Window("Button". w1. 3. [VBScript] Sub Test1 Dim p1 Dim w1 TestedApps.HScroll.Pos = 0 Call w1. For example. "*"). "*"). w1 = p1. "&No").Click(135.Window("Edit"). "Notepad").ClickButton(). Add the variable "Var1" to the master project.Window("Notepad".Keys(NetworkSuite. 29) Set w1 = p1.Run Set p1 = Sys.Synchronize("SynchPoint1") Call w1.2.Distributed Testing 271 w1 = p1. Using SyncPoints 1.Window("Edit"). Modify the test in hosted (slave) project.Keys("[Enter]") NetworkSuite.Window("Button".VScroll. w1. } 2.Var1) w1.Click(135. w1.Pos = 0.0 Release . Right-click the NetworkSuite project item and select Run from the context menu.Var1) Call w1. "Notepad").Window("Edit") w1. Synchronizing Computers There are times when you want to have one computer wait for another computer to complete at least part of its task before finishing the first computer's task.

0 Release . w1 = p1. NetworkSuite.Window("Notepad". w1.Variables.Var1 = "Rocks". select Add | New Item. "*")..Pos = 0. Right-click the SyncPoints Project Item.WaitForState(ns_Idle).. NetworkSuite. "&No").VScroll. Right-Click in the newly created script and select Run Current Routine from the context menu..Close(). NetworkSuite.Pos = 0.WaitForState(ns_Running) Delay(30000) NetworkSuite. w1. 29). from the context menu.ClickButton(). 6.Var1 = "TestComplete". Hit Enter on the Create Project Item dialog. 3.Keys("[Enter]").HScroll.Var1 = "Rocks" NetworkSuite.Synchronize("SynchPoint1").Run(false).WaitForState(ns_Running). w1.Window("Notepad". "Notepad").Synchronize("SynchPoint1").Run(false) NetworkSuite. Create a script in the master project.WaitForState(ns_Idle) End Sub [JScript] function Test1() { NetworkSuite.Window("Edit").Keys(NetworkSuite. Hit Enter on the Create Project Item dialog. Copyright © 2009 AutomatedQA Corp. NetworkSuite. w1 = p1. [VBScript] Sub Test1 NetworkSuite.Window("Edit"). w1. w1. select Add | New Item.Run().272 TestComplete 7 Made Easy [JScript] function Test1() { var p1 var w1 TestedApps.Synchronize("SynchPoint1") NetworkSuite.notepad. "*"). } 5.Window("Button".Variables. 4. NetworkSuite.Variables. w1.. NetworkSuite.Process("notepad"). } 2. p1.Variables. 7. Right-click the SyncPoints Project Item. .Window("Edit").Click(135. from the context menu.Var1).Window("#32770".2. Delay(30000). p1 = Sys.

Pos = 0.Window("#32770".2.Variables. p1.Run(false) Call NetworkSuite.Window("Notepad". "TestComplete" will be typed. NetworkSuite. "*"). 29) Set w1 = p1.Window("Edit") w1.Window("Edit"). "*"). w1. [VBScript] Sub Test1 Dim p1 Dim w1 TestedApps.Window("#32770". Using NetworkSuite Variables 1.false). "*").WaitForNetVarChange("Var2".Variables.VScroll.Keys(NetworkSuite.Variables. Modify the test in hosted (slave) project. w1.Pos = 0.Window("Edit").Keys("[Enter]") NetworkSuite.Variables.Var1).Variables.Var1 = "TestComplete" NetworkSuite. .0 Release .ClickButton(). w1.Close p1.Click(135.Var1) Call w1.Variables.Distributed Testing 273 On the hosted computer.notepad.Window("Button". "Notepad").Window("Edit").Pos = 0 w1. [VBScript] Sub Test2 NetworkSuite.WaitForNetVarChange("Var2".HScroll. "Notepad").Variables. Create a script in the master project.Window("Edit"). "&No").ClickButton End Sub [JScript] function Test1() { var p1 var w1 TestedApps.Var1). w1.Keys(NetworkSuite.Window("Button".false) Call w1.Window("Edit").Keys("[Enter]"). w1. } 2. p1 = Sys. w1. w1 = p1.Var1) w1. followed by a delay and then on a new line "Rocks" will be typed.Keys(NetworkSuite.notepad.Window("Notepad".Run().Window("Edit"). "&No").WaitForNetVarChange("Var2". w1.Window("Notepad".Keys(NetworkSuite.Pos = 0 Call w1. NetworkSuite.Var2 = true.Window("Edit").Window("Notepad".Var1 = "Rocks" Copyright © 2009 AutomatedQA Corp.VScroll.Process("notepad").HScroll.Var2 = True Call NetworkSuite.Variables. w1 = p1.true) NetworkSuite. "*") Call w1.Close(). 29).Click(135.Process("notepad") Set w1 = p1.Run Set p1 = Sys.

NetworkSuite. .WaitForNetVarChange("Var2". The hosted computer will do the same things as the SyncPoint demo.Run(false). 21.Variables. NetworkSuite. but with less delay in the project.true). NetworkSuite.Variables.Var1 = "TestComplete". Add the variable "Var2" to the master project in the NetworkSuite project item.Var1 = "Rocks". We also learned how to script Distributed Tests using Synchronize Points and Network Suite Variables. 4.WaitForState(ns_Idle) End Sub [JScript] function Test2() { NetworkSuite.Variables.WaitForState(ns_Idle).0 Release . } 3.274 TestComplete 7 Made Easy NetworkSuite. Right-click in the newly created script and select Run Current Routine from the context menu. Copyright © 2009 AutomatedQA Corp. NetworkSuite.Var2 = false.Var2 = False NetworkSuite.2. Notice that the hosted computer can pass data back to the master computer.Variables.7 Summary In this section we learned how tests are run on several computers at the same time. NetworkSuite.

Part XXII User Forms .

The middle is the actual user form. · How to access user forms in script. In our example.276 TestComplete 7 Made Easy 22 22. Copyright © 2009 AutomatedQA Corp... The UserForms project item is a holder (folder) for all the user forms created in the project. Rad Studio). Eclipse. TcxButton (Buttons Category) and TcxLabel (Helpers Category).1 User Forms Objectives This section demonstrates how to create user forms and manipulate them using script: In this section you'll learn: · What is a user form. we will create a simple user name and password dialog. 22. . The left side of the editor contains the components that can be added to the user form. The components that we use are TcxTextEdit (from the Editors Category). We will use two of each.). Components are added by dragging with the mouse and dropping on the form. First add the UserForms project Item to the project. · Learn how to create an user form. The next step is to add an user form to the project (right-click of the UserForms project item and Add | New Items. And the right side is where the properties and events are setup.0 Release .2 Creating Creating a user form in TestComplete is very similar to creating a form in most development IDEs (Visual Studio.2.

0 Release .2.User Forms 277 We will also need to set the properties for all of the components (only changed properties shown): Property User Form Caption Height Width cxButton1 Caption Default ModalResult cxButton2 Cancel Caption ModelResult cxLabel1 Caption cxLabel2 Caption edtUser (Renamed from cxTextEdit1) Password: User Name: True Cancel mrCancel OK True mrOK Enter Login Information: 130 450 Value Copyright © 2009 AutomatedQA Corp. .

} 22.Show() and ShowModal().Text) End Sub [JScript] function Main() { //Fill in the current user name UserForms.edtUser.Halt("User Cancelled Test") end If Log.Halt("User Cancelled Test"). we learned the basics of creating a user form.ShowModal = mrCancel Then Runner.Text + " Logged in with Password: " + UserForms.edtPassword. Copyright © 2009 AutomatedQA Corp. Log.edtUser. There are two method used to display an user form . [VBScript] Sub Main 'Fill in the current user name UserForms. which displays the user form and stops the script from playing until the user answers the dialog.UserNameAndPassword.UserNameAndPassword.UserName.278 TestComplete 7 Made Easy Name edtPassword (Renamed for cxTextEdit2) Name Properties.edtUser.Text = Sys. if (UserForms. .UserNameAndPassword.ShowModal() == mrCancel) Runner.4 Summary In this chapter.UserName if UserForms.UserNameAndPassword.edtUser.Text = Sys.UserNameAndPassword.UserNameAndPassword.edtPassword.Text).0 Release .UserNameAndPassword.Message("User: " + UserForms.EchoMode edtUser edtPassword eemPassword 22.Text &_ " Logged in with Password: " &_ UserForms.Message("User: " & UserForms.2.UserNameAndPassword.3 Scripting Now that we have created a user form. Note: Show() will continue with the next line in the script code. we need to learn how to use the form in a script. Then we learned how to display the form to the user and get information from the form. In our example we will use ShowModal ().

Part XXIII Best Practices .

· Use the TestItems of the project as a framework for Test Cases. · Separate Data from the Test Framework (see Data-Driven Testing).0 Release . Copyright © 2009 AutomatedQA Corp.2. etc.280 TestComplete 7 Made Easy 23 23. · Use the code metrics of the Code Explorer to improve the quality of the script code.1 Best Practices General The following are general tips and best practices to help you get the most out of TestComplete: · Record/Playback is a quick and easy way to get automated tests up and running but tend to be brittle leading to problems when the application changes. .

.2. · Keep routines short (less than a page of code).0 Release .Best Practices 281 · Use reusable routines whenever possible. Copyright © 2009 AutomatedQA Corp. · Use meaningful variable names (The default variable names of a recording are not very good variable names).

.2.0 Release .2 Web Page The following are tips for making effective use of TestComplete when testing web pages: · Make the Page object a child of the browser process.282 TestComplete 7 Made Easy 23. Copyright © 2009 AutomatedQA Corp. · Use either the Hybrid or Tree "Tree Model".

Part XXIV Cheat Sheet .

.0 Release .1 Cheat Sheet Keyboard Shortcuts Global Shortcuts (keys that work when TestComplete is running even if TestComplete does not have focus) Command Pause script execution Fix Information Record Stop Run Pause recording Load Testing Record Low Level Record Default Key SHIFT-10 SHIFT-CTRL-A SHIFT-F1 SHIFT-F2 SHIFT-F3 SHIFT-F11 SHIFT-F6 SHIFT-F4 Key Mapping (keys that work when TestComplete has focus.284 TestComplete 7 Made Easy 24 24. generally in the editors) Command/Section Debugging Run Reset Step Over Trace Into Run to Cursor Switch Breakpoint View Evaluate View Call Stack View Watches View Break Points Project/Units Close Page CTRL-F4 CTRL-F4 ALT-F3 F9 CTRL-F2 F8 F7 F4 F5 CTRL-F7 CTRL-ALT-S CTRL-ALT-W CTRL-ALT-B F5 SHIFT-F5 F10 F11 F4 F9 CTRL-F2 ALT-7 ALT-3 CTRL-B F9 CTRL-F2 F8 F7 F4 CTRL-F8 CTRL-F4 CTRL-ALT-S CTRL-ALT-W CTRL-ALT-B Default Visual Studio Borland Classic Copyright © 2009 AutomatedQA Corp.2.

Cheat Sheet 285 Save Unit Open Project New Project Save All Display previous page Display next page Cursor movement Cursor Left Cursor Right Beginning of Line End of Line Up one line Down one line Up one page Down one page Beginning of Document End of Document Move to word before Move to word after Delete operations CTRL-S CTRL-F11 CTRL-S CTRL-SHIFT-0 CTRL-SHIFT-N CTRL-SHIFT-S CTRL-S CTRL-F11 CTRL-SHIFT-S CTRL-SHIFT-TAB CTRL-TAB CTRL-SHIFT-TAB CTRL-TAB CTRL-SHIFT-TAB CTRL-TAB LEFT RIGHT HOME END UP DOWN PGUP PGDN CTRL-HOME CTRL-END CTRL-LEFT CTRL-RIGHT LEFT RIGHT HOME END UP DOWN PGUP PGDN CTRL-HOME CTRL-END CTRL-LEFT CTRL-RIGHT LEFT RIGHT HOME END UP DOWN PGUP PGDN CTRL-PGUP CTRL-PGDN CTRL-LEFT CTRL-RIGHT Delete character at cursor DEL Delete character before cursor Delete current line Delete previous word Delete next word Miscellaneous Indent selected block Unindent selected block CTRL-SHIFT-I or TAB BACKSPACE CTRL-Y CTRL-BACKSPACE CTRL-T DEL BACKSPACE CTRL-SHIFT-L CTRL-BACKSPACE CTRL-DEL DEL BACKSPACE CTRL-Y CTRL-BACKSPACE CTRL-T CTRL-SHIFT-I CTRL-SHIFT-I CTRL-SHIFT-U CTRL-SHIFT-U or SHIFT.0 Release .2.CTRL-SHIFT-U TAB Copyright © 2009 AutomatedQA Corp. .

If you accidentally close Copyright © 2009 AutomatedQA Corp.0 Release .286 TestComplete 7 Made Easy Toggle insert/overwrite mode Undo Redo INS CTRL-Z or ALTBACKSPACE SHIFT-CTRL-Z or INS CTRL-Z or ALTBACKSPACE SHIFT-CTRL-Z or INS ALT-BACKSPACE ALT-SHIFT-BACKSPACE ALT-SHIFT-BACKSPACE ALT-SHIFT-BACKSPACE Print CTRL-P CTRL-P CTRL-UP CTRL-DOWN ALT-F10 (Code Editor only) CTRL-F CTRL-H F3 CTRL-A CTRL-SPACE CTRL-J CTRL-SPACE CTRL-J CTRL-P CTRL-W CTRL-Z ALT-F10 (Code Editor only) CTRL-F CTRL-R CTRL-L Scroll display up one line CTRL-UP Scroll display down one line Display context menu Find Replace Search Again Select All Invoke Code Completion Code Templates Bookmarks Set Numbered Bookmark CTRL-SHIFT-# Goto Numbered Bookmark Set Unnumbered Bookmark Goto Unnumbered Bookmark Clipboard Cut to Clipboard Copy to Clipboard Paste from Clipboard CTRL-X or SHIFT-DEL CTRL-C or CTRL-INS CTRL-V or SHIFT-INS CTRL-# CTRL-SHIFT-' CTRL-' CTRL-DOWN ALT-F10 (Code Editor only) CTRL-F CTRL-R F3 CTRL-A CTRL-SPACE CTRL-J CTRL-SHIFT-# CTRL-# CTRL-SHIFT-' CTRL-' CTRL-SHIFT-# CTRL-# CTRL-SHIFT-' CTRL-' CTRL-X or SHIFT-DEL CTRL-C or CTRL-INS CTRL-V or SHIFT-INS CTRL-X or SHIFT-DEL CTRL-C or CTRL-INS CTRL-V or SHIFT-INS 24.2. .2 Code Completion TestComplete will automatically display the code completion dialog by default.

24. you can find out what parameters are needed by the method by pressing "CTRL-SHIFT-SPACE" inside the parentheses.0 Release . Global Shortcuts (keys that work when TestComplete is running even if TestComplete does not have focus) Copyright © 2009 AutomatedQA Corp. .2.Cheat Sheet 287 this dialog (or you have turned Autocompletion off). the code completion dialog can be invoked by press "CTRL-SPACE" For method known by TestComplete.3 Keyboard Handling in Recorder TestComplete will record all keys entered to the active control while recording except for any keys that are in the Global Shortcuts.

4 Global Shortcuts/Changing Keyboard Emulation To access and change the Global Shortcuts: · Select "Tools | Options" from the main menu · Select "General | Global Shortcuts" from the Options dialog.2.288 TestComplete 7 Made Easy Command Pause script execution Fix Information Record Stop Run Pause recording Load Testing Record Low Level Record Default Key SHIFT-10 SHIFT-CTRL-A SHIFT-F1 SHIFT-F2 SHIFT-F3 SHIFT-F11 SHIFT-F6 SHIFT-F4 24.0 Release . Copyright © 2009 AutomatedQA Corp. .

. · Choose the keyboard emulation that you want.. you will need to clear the one using it first).2. (You can also set keyboard shortcuts for any command in this dialog). Copyright © 2009 AutomatedQA Corp.. To access and change the keyboard emulation: · Select "Tools | Customize Keyboard.0 Release .Cheat Sheet 289 · Select the Action · Type in the new keyboard shortcut (note: if it is already in use." from the main menu.

290 TestComplete 7 Made Easy Copyright © 2009 AutomatedQA Corp.0 Release .2. .

Part XXV AutomatedQA .

Some of their competitors charge separately for different test types like GUI testing. an exact Copyright © 2009 AutomatedQA Corp.0 and 3. you will quickly know the exact speed. A good example is their automated testing tool. and on providing users with fast and accurate product support each and every day. United States. AQtime Debug. It’s this combination of affordability and features that led Joel Spolsky. AQtime 6. AutomatedQA has an impressive list of customers ranging from huge teams in the world's largest organizations to progressive one-developer shops. This is all done without modifying the application's source code! With AQtime's intuitive and user-friendly interface and instrumentation in hand. with all of the tools you need to begin the optimization process. Compaq and GNU compilers.0.NET and Windows applications. of joelonsoftware.com to write. AQtime supports . The latest version of AQtime. for considerably less.and 64-bit applications. TestComplete includes all supported testing types in one product with more features. “AutomatedQA's TestComplete is a great product and just as capable as the market leader at less than one-tenth the price.2. Optimize.5 applications and Windows 32.1 AutomatedQA History AutomatedQA offers software products and services for development and quality assurance projects worldwide.to help you completely understand how your programs perform during execution. Intel. a sophisticated performance and memory profiler.1. AutomatedQA was founded in 1999 with headquarters in Las Vegas. TestComplete. AQtime collects crucial performance and memory/resource allocation information at runtime and delivers it to you both in summarized and detailed forms. AQtime. award-winning and affordable products for the entire software development lifecycle including TestComplete for test automation and AQtime. 1. and application usability issues in your programs. . memory usage. 2. unit testing and load testing. Automated Build Studio. This include TestComplete. It means that their solutions tend to cost a fraction of their competitor's prices and offer more features. AutomatedQA’s guiding principle is to be wholly focused on providing affordable and feature-rich developer tools and quality assurance technologies. AQtime provides all the tools to compare and merge results so that over time. Using its integrated set of performance and debugging profilers.Joel Spolsky 25. As you optimize and improve your code. 3. They create innovative.0. Borland.0 Release .292 TestComplete 7 Made Easy 25 25. AQtime is built with one key objective . includes dozens of productivity tools that help you easily isolate and eliminate all performance issues and memory/resource leaks within your code by generating comprehensive and detailed reports for your .2 Product Offerings AutomatedQA offers several products in the Software Application LifeCycle Management sector.NET 1. What does affordable and feature-rich mean? It means bang for the buck. Nevada. -. and Deliver Rock Solid Applications AQtime is AutomatedQA's award-winning performance profiling and memory and resource debugging toolset for Microsoft. Why would anybody pay $6000 per seat for test automation?”. AQdevTeam and other derivatives of the main products like TestExecute and TestRecorder.

· Ensure that you make the right code improvements from day one. · Helps drill down to the exact line of source code that is responsible for performance or memory allocation inefficiencies.AutomatedQA 293 and accurate "picture" of your application's state takes shape: · Monitor and report on all areas that could degrade your project’s performance and quality. testing and releasing of software projects consumes an ever-increasing amount of time and resources.2. Automated Build Studio is a powerful build and release management system that provides an easy way to automate the software development build. Its intuitive interface and unprecedented flexibility allows even inexperienced users to create complex visual macros which can Copyright © 2009 AutomatedQA Corp. with projects becoming more and more complex. test and release processes. Tests and Deployment In the current state of software development.0 Release . . · Assess the thoroughness of your tests by using Coverage Profiling. Automated Build Studio Automate Software Builds. building.

Copyright © 2009 AutomatedQA Corp. · Create deployment packages and write them to CD and/or DVD. Jscript or DelphiScript) or many other operations. FTP server. . · Automate data and system consistency checks (for example. Web site. ICQ and newsgroup notifications · Burn CDs and DVDs · Register COM and ..) · Extract and pack files from/to ZIP and RAR archives · Run automated test scripts and profilers · Post bug reports to issue-tracking systems · Send and receive e-mail. etc. Automated Build Studio contains over 540 built-in operations that will help you: · Compile applications · Create installation packages · Perform automated builds as scheduled tasks · Get and put files from/into version control systems · Label sources in version control systems · Compile help files · Create.0 Release . Even though the product name includes the word “build”. With Automated Build Studio you can: · Automate your software builds · Perform distributed builds · Automate the process of application testing and profiling. you can use Automated Build Studio to automate any common or everyday tasks in your organization.NET components · Perform scripting operations in any of 3 scripting languages (VBScript.294 TestComplete 7 Made Easy automate repetitive or day-to-day tasks with the single click of a button. modify and delete registry keys and INI file settings · Copy and move files to a location (network drive. you can automate checking the free disk space or the availability of a Web service).2. · Automate back-up processes..

using a simple. TestExecute gives QA departments the ability to test applications in real life user environments .0 Release .without the need to install TestComplete on the target machine.such as at customer sites . resource friendly command-line utility.2.AutomatedQA 295 TestExecute TestExecute allows you to execute scripts written with TestComplete and log test results on machines that do not have TestComplete installed . Copyright © 2009 AutomatedQA Corp. .

0 Release . Once incorporated into your app. . These scripts tell you exactly what a user was doing during application execution . Later.296 TestComplete 7 Made Easy TestRecorder TestRecorder is a set of runtime libraries to be distributed with your 32-bit and 64-bit applications. DelphiScript. Jscript.allowing you to accurately repeat the sequence of user actions via TestComplete or TestExecute. Copyright © 2009 AutomatedQA Corp.2. TestRecorder fully records end-user actions in the binary format. C++Script or C#Script. the recorded data can be converted with TestComplete to an easily readable script code in VBScript.

Part XXVI Professional Offering .

You may also visit http://www. TestCompleteTV. Falafel’s consultants have been working with TestComplete since the very beginning and are the highest qualified individuals to assist you. Online Training: For companies that have team members in multiple locations or in situations where onsite training is not feasible.com/partners to find a partner that fits your needs.automatedqa. Go to www. AutomatedQA’s premier services partner. Visit www. online training is a great option. Falafel has a wide range of services ranging from TestComplete training and consulting to large-scale custom enterprise application development.0 Release . TestComplete Consulting from Falafel Software On a deadline? Need assistance from the Pros? Let Falafel provide you with world-class consulting for all your TestComplete needs.2.com/forums.com/products/testcomplete/screencasts/ for helpful screencasts and videos.automatedqa.298 TestComplete 7 Made Easy 26 Professional Offering Support and Services Support You can get your support questions answered by posting a message on the AutomatedQA message boards www.com/support for all your support options. this open-enrollment option is the most cost effective solution. . The professionals from Falafel Software are great to work with and we hear nothing but effusive praise about them from our customers. Here’s a description of some of their TestComplete related services: TestComplete Training from Falafel Software Onsite Training: A highly knowledgeable Falafel Software trainer will come to you and provide your team with an enlightening 3-5 day class.com from Falafel Software TestComplete TV from Falafel Software provides an abundance of training videos that let you to Copyright © 2009 AutomatedQA Corp. Services AutomatedQA’s worldwide network of partners can provide your organization with training and services to help you ramp up more quickly or help with your existing automated testing projects. This is the best way to ramp up quickly. TestComplete Training and Services from Falafel Software The authors of this book are from Falafel Software.automatedqa.automatedqa. Training Summit: If your team only has a few individuals in need of training.

For more info on Falafel Software. This is an inexpensive subscription solution the guys at Falafel Software know you will love. Copyright © 2009 AutomatedQA Corp.falafel. go to www.Professional Offering 299 learn at your own pace in an innovative environment.com for more information.2.0 Release . .com or call 1-888-GOT-FALAFEL (1-888-4683252). Check out TestCompleteTV.

39 Cookie Handling 239 Copy Script to Editor 48 CPU 47 CSVDriver 165 Customize 42 -664 bit 12 -DDDT 165 Debugging 63. 57 -332 bit 12 Code Options 61 Code Templates 61 Complex types 219 Condition 63 Connections 241 Consulting 298 Continuous Integration 37. .300 TestComplete 7 Made Easy Index -. 150.0 Release . 60 Email 90 Eric Holton 292 Evaluate 66 ExcelDriver 165 Extended Information 89 -FFile Comparison 150 Files 150 Find 203 Finder tool 50 Firewall Settings 237 Functional Testing 36 -BBlack Box 56 Bookmarks 60 Breakpoints 63 Build 36 -CCall Stack 64 Checkpoint 142. 292 -EEditor 59..2. 64.NET 12. 154 Code Completion 59. 66 Delay 136 DHTML 205 Distributed Testing 36. 280 -GGeneral Events Global Variables Gutter 61 173 65 Copyright © 2009 AutomatedQA Corp. 268 DOM 196 DUnit 104 -AActivate 136 ActiveFocus 142 Add Text To Script 128 ADO 183 ADODriver 165 AJAX 205 Aliases 102 Analysis 244 AppendFolder 89 Application 36 AQDevTeam 292 AQTime 292 Automated Build Studio 292 AutomatedQA 12. 286 Code Explorer 44. 65.

242. 287. 253 HTTP Performance Testing 36 HTTP Traffic 246 Hybrid 196 -NNamed Mappings 94.0 Release . 105 -OObject Browser 47 Object Comparison 154 Object Name Mapping 101 Object Properties 48 Objects 154 OnBeforeStep 120 OnLogError 175 OS 47 -JJava Jobs JUnit 12 266 104 -KKeyboard 284. . 99. 237 Local Variables 65 Locals 65 LockEvents 91 Log Tree 89 Low Level Procedure 133 Low Level Procedure Collection 133 -MManual Steps 113 Manual Test 120 Map to Object 94 Mapping Dialog 101 Maunal Test 112. 75 Project Items 84 Project Structure 75 Project Suite 44 Project Template 79 Project Wizard 75 Project Worksapce 44 Proxy Settings 237 -LLoad Testing 36. 239.2. 102 Naming convention 197 NativeWebObject 203 Network Suites 263 Notepad 50 NUnit 104. 288 Keyboard events 136 -PParameter Completion 59. 113 Maunal Test Events 120 Maunal Testing 36 Menus 42 Mouse events 136 MSTest 104 -QQA 36 Copyright © 2009 AutomatedQA Corp. 286 Pass Count 63 Pausing 130 Playback 126 Plug-ins 84 PopLogFolder 89 Process Filter 48 Professional Offering 298 Profile 85 Project Anatomy 75 Project Explorer 44 Project Item 44.Index 301 -HHighlight Object 99 Highlight on Screen 50 Hosts 265 HTTP Load Test 268 HTTP Load Testing 237. 101.

292 TestedApps 85 TestExecute 292 TestRecorder 292 Tests 239 Toolbar 42 Training 298 Tree 196 -UUnexpected Windows 176 Unit Testing 36. 246 Responses 241. 257.0 Release . 266 TCUnitTest 104 Test Items 280 Test Log 244 Test Logs 90 -XXAML 12 XML Checkpoint 226 Copyright © 2009 AutomatedQA Corp. 288 ShowModal 278 Smoke Test 39 Sort 48 Source Code Control 37 SQL Server 183 SQL Server 2005 183 Stations 239. 104. 226 Web Services Testing Dialogs 224 Web Testing 205 WebServices Checkpoint 219 White Box 56 White Box Application 57 Window Coordinates 133 Windows 12 WinformsObject 57 WndCaption 50 Workspace 44 WSDL 214 -TTag 196 Tasks 239. 244 Run As 85 Run Mode 85 TestComplete 12. 246 Result Logs 44.302 TestComplete 7 Made Easy -RR&D 36 RAM 47 Recording 126. 129. 239 Recording Toolbar 127 Reflection 57 Region Comparison 142 Regions 142 Regression Testing 36 Remote Agent 253. 255 Remote Agent Port 255 Remote Agent Proxy 255 Requests 241. 287. 257 Stopping 130 Stress Testing 237 SynchPoints 267 -WWatch List 66 Web Accessibility Checkpoint 200 Web Comparison Checkpoint 197 Web Page 282 Web Page Model 196 Web Services Options 224 Web Services Testing 214. .2. 278 -VVirtual Users 242 -SScalability Testing 237 Screen Coordinates 133 script Log 89 Service mode 253 SetFocus 136 Shortcuts 284. 108 User Forms 276. 219.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->