Book Image

TestComplete Cookbook

By : Gennadiy Alpaev
Book Image

TestComplete Cookbook

By: Gennadiy Alpaev

Overview of this book

<p>TestComplete is an automated testing tool, designed for advanced and novice testers alike, to create, manage and run tests for any desktop, Web or rich client software. It does not depend on any development tool, or application type. Your tests will work fine with any application regardless of whether it was created in C#, C++, Delphi, Java, or any other development language. TestComplete is the most efficient tool of its kind, in regards to the price and quality of the product.</p> <p>This guide takes a refined approach towards quickly learning the capabilities of TestComplete, using relevant illustrations and practical examples. Each example is consonant with true-to-life situations, which testers would come across sooner or later, while automating tests. With the help of these examples, we will look into complex themes and learn how to test web applications in the most effective manner.</p> <p>Throughout the first chapters, we will be dealing with some fairly simple tasks that are of interest to people new to TestComplete, gradually moving towards advanced-level automation approaches, which are riveting both for novices and experienced TestComplete users.</p> <p>We will explore various methods of tests creation for study (e.g. recording, modification and manual coding with use of different approaches), learn test creation using different methods(each of them being suitable for a specific use-case), learn how to distinguish between different methods for accessing controls elements, selecting a most appropriate approach for each of the cases in view. We will also undertake distributive testing for the sake of shortening the overall time for test launches.</p> <p>This practical guide will help you to answer frequently asked questions relating to automation testing and set the tone for the correct direction of your advancements, which are instrumental to organizing automation in your project.</p>
Table of Contents (19 chapters)
TestComplete Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Testing automation is a tricky and complex area of computer science, as it requires not only experience in both testing and programming, but also knowing some specifics of using Graphical User Interface (GUI).

During the last several years a lot of software has been created to help to automate testing by emulating users' actions. Some of these programs are strictly specialized, while others allow users to automate a wide range of software.

TestComplete is one of the tools which supports testing of software developed on different platforms and application types (.NET, Win32, Java, Delphi, Web, and so on), at the same time using similar techniques for all of them, thus simplifying process of automation by software testers.

This book will teach you how to effectively use TestComplete by many simple and well thought-out examples, at the same time showing how to solve the most frequently asked questions. By executing the steps from each recipe and then reading the explanation text of what has been done, you will master TestComplete quickly and easily.

We hope this book will be a great support to you in studying TestComplete and testing automation principles.

What this book covers

Chapter 1, Getting Started, provides basic information about TestComplete and prepares you for further topics. This chapter will be helpful if you are new to TestComplete.

Chapter 2, Working with Tested Applications, explains how to work with tested applications in TestComplete using different approaches.

Chapter 3, Scripting, provides programming solutions for frequently asked questions and shows examples of different testing methodologies and frameworks.

Chapter 4, Running Tests, explains how to run your TestComplete tests including running from command line and scheduling automatic test runs.

Chapter 5, Accessing Windows, Controls, and Properties, explains how TestComplete interacts with tested applications, their controls, and data within windows.

Chapter 6, Logging Capabilities, covers several topics related to TestComplete log including working with screenshots, exporting logs, and sending results via e-mail.

Chapter 7, Debugging Scripts, describes how to use TestComplete debug capabilities when maintaining tests.

Chapter 8, Keyword Tests, introduces a simple way to create automated tests which doesn't require programming skills.

Chapter 9, Data-driven Testing, explains how to separate scripts code from test data and effectively work with it in tests.

Chapter 10, Testing Web Applications, covers Web-specific topics which were not covered in other chapters.

Chapter 11, Distributed Testing, shows how to run tests on several workstations and share data between them.

Chapter 12, Events Handling, introduces TestComplete events—a powerful tool to customize and improve your testing framework.

What you need for this book

To run the examples in the book the following software will be required:

  • Microsoft Windows 7 x86 (32 bits) Home, Professional, Ultimate, or Enterprise Edition (most examples will also work in 64-bits version of the OS)

  • SmartBear TestComplete 9.0 or higher (most examples will also work in TestComplete 7.x and 8.x)

  • Microsoft Calculator Plus 1.0

  • Mozilla Firefox (any version supported by selected TestComplete version)

Who this book is for

If you wish to use TestComplete for testing automation, this book will help you learn the very basics of the tool, as well as improve your knowledge if you already have some experience in working with TestComplete.

The recipes provided in this book can be studied one by one, thus improving your knowledge step-by-step. The book can also be read randomly, depending on the type of problem that you are trying to resolve.

It is implied that you are already aware of the programming basics (knowing what is a variable, loop, condition, function). This will tremendously facilitate further understanding of the approaches and solutions that are being considered. Nonetheless, we have tried to select examples that would be easy to understand, even for a novice in programming. These examples are easily scalable for your specific needs, as well as portable and scalable.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles, are shown as follows: "The Runner.CallObjectMethodAsync method accepts two parameters: the object and the callee method."

A block of code is set as follows:

function testPirtureFormat()
{
  Options.Images.ImageFormat = "BMP";
  Log.Picture(Sys.Desktop.Picture(), "BMP screenshot");
  Options.Images.ImageFormat = "PNG";
  Log.Picture(Sys.Desktop.Picture(), "PNG screenshot");
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

TestedApps.notepad.Close();
  if(pNotepad.WaitWindow("#32770", "Notepad", -1, 1000).Exists)
  {
    pNotepad.Window("#32770", "Notepad").Keys("~n");
  }

Any command-line input or output is written as follows:

C:\Program Files\SmartBear\TestComplete 9\Bin\TestComplete.exe" "z:\TestCompleteCookBook\TestCompleteCookBook.pjs" /run /project:Chapter4 /Unit:Unit1 /routine:testDemoTestItems2

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Configure button in the Images group".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.