Book Image

Advanced UFT 12 for Test Engineers Cookbook

Book Image

Advanced UFT 12 for Test Engineers Cookbook

Overview of this book

Table of Contents (18 chapters)
Advanced UFT 12 for Test Engineers Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Drawing a rectangle on the screen with Win32 API methods (Extern)


In this recipe, you will also see an example of how to use the Extern reserved object to define references to methods in external DLLs such as those of the Win32 API. These methods can then be loaded and executed during runtime. We have already seen an example of this in the Reading values from an INI file recipe in Chapter 1, Data-driven Tests. Here, we will learn how to implement a function that draws a rectangle on the screen with the color of your choice. This is useful to mark areas on the screen that are of interest (especially when the test fails) and hence, makes the report analysis task more efficient.

Getting ready

From the File menu, navigate to New | Test, or use the Ctrl + N shortcut.

To complete this recipe, we need the global Extern object, which, with proper use, provides UFT with access to the methods of an external Dynamic Link Library (DLL). We will define a variable and assign it a reference to the global...