PacktLib: TestComplete Cookbook

TestComplete Cookbook

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

Getting Started

Introduction

Installing TestComplete

Creating your first project

Choosing a scripting language for the project

Recording your first test

Modifying the recorded test

Saving and restoring user settings

Creating code templates

Delaying script execution

Adding and removing project items

Understanding how TestComplete interacts with tested applications

Understanding Object Browser

Using Object Spy

Working with Tested Applications

Introduction

Adding a tested application project item

Running a tested application from the script

Terminating a tested application

Killing several instances of a tested application

Closing a tested application

Running a tested application in the Debug mode

Running a tested application under a different user account

Changing tested application settings dynamically from the script

Running external programs and DOS commands

Testing installers – running an MSI file

Scripting

Introduction

Entering text into text fields

Using wildcards to process objects with variable names

Structuring code using loops

Creating property checkpoints

Creating object checkpoints

Using global variables

Testing multilingual applications

Working with nonstandard controls

Organizing script code in the project

Handling exceptions

Handling exceptions from a different unit

Creating framework using the OOP approach

Running Tests

Introduction

Running a single function

Verifying test accuracy

Creating a test plan for regular runs

Running tests from the command line

Passing additional parameters to test from the command line

Organizing test plan runs

Scheduling automatic runs at nighttime

Running tests via Remote Desktop

Changing playback options

Increasing run speed

Disabling a screensaver when running scripts

Sending messages to Indicator

Showing a message window during a script run

Accessing Windows, Controls, and Properties

Introduction

Choosing Object Tree Model

Understanding the window's life cycle

Ignoring overlapping windows

Dragging one object into another

Calling methods asynchronously

Verifying if an object has a specific property

Finding objects by properties' values

Waiting for an object to appear

Waiting for a property value

Mapping custom control classes to standard ones

Using text recognition to access text from nonstandard controls

Using Optical Character Recognition (OCR)

Dealing with self-drawn controls not supported by TestComplete

Logging Capabilities

Introduction

Posting messages to the log

Posting screenshots to the log

Creating folders in the log

Changing log messages' appearance

Assessing the number of errors in the log

Changing pictures' format

Comparing screenshots with dynamic content

Decreasing log size

Generating log in our own format

Exporting log to MHT format

Sending logs via e-mail

Debugging Scripts

Introduction

Enabling and disabling debugging

Using breakpoints to pause script execution

Viewing variables' values

Debugging tests step by step

Evaluating expressions

Keyword Tests

Introduction

Recording and understanding Keyword Tests

Adding new actions to existing Keyword Tests

Enhancing Keyword Tests using loops

Creating object checkpoints

Calling script functions from Keyword Tests

Converting Keyword Tests to scripts

Creating our own Keyword driver

Data-driven Testing

Introduction

Generating random data for tests

Accessing a specific cell in a table

Reading all data from a table

Using DDT tables for storing expected values

Changing CSV delimiter and other parameters

Driving data without using loops

Accessing Excel spreadsheets without having MS Office installed

Auto-detecting Excel driver

Testing Web Applications

Introduction

Choosing Web Tree Model

Using updates for the latest browser versions

Performing cross-browser testing

Verifying if a text exists on a page

Waiting for an element to appear on a page

Saving screenshots of an entire page

Running scripts on a page

Distributed Testing

Introduction

Setting up Network Suite and understanding distributed testing

Copying Project Suite to a Slave workstation

Using a Master workstation to run tests

Using different configuration files for each workstation

Sharing data between workstations

Synchronizing test runs on several workstations

Events Handling

Introduction

Creating event handlers

Disabling the postage of certain error messages

Clicking on disabled controls without an error message

Handling unexpected windows that affect TestComplete

Handling unexpected windows that don't affect TestComplete

Saving the log to a disk after each test

Sending a notification e-mail on timeouts

Creating preconditions and postconditions for tests

Index