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

Overriding a Test Object method


In this recipe, we will see how to write a new implementation of a method for a TO.

Getting ready

From the File menu, navigate to New | Function Library… or use the Alt + Shift + N shortcut. Name the new function library as FR_RegFunc.vbs.

How to do it...

As always, with programming, the task needs to be addressed in an orderly fashion. Therefore, there is a series of implementation steps to follow:

  1. Analyze the requirement, which means ask questions. For example:

    • What are the missing functions?

    • To which object class is it relevant?

  2. Design the solution.

  3. Code the function.

  4. Test the function.

  5. Register the function to the required object class.

In the following example, we will write a function in FR_RegFunc.vbs that overrides the WinEdit_Set method. The new method will try to set the field, and if an error occurs, it will check if there is a modal pop-up message that has opened in the Flight Reservation application (refer to Chapter 1, Data-driven Test). If it has opened...