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

Identifying an object based on its parent


In some cases, a TO may appear repeatedly on a window or page. A common example is images that are used as buttons in web applications. If a function is called to perform an action on such a TO, we may need to ensure that the correct object was passed. A powerful technique to achieve this is already outlined in the Identifying elements based on anchors recipe in Chapter 2, Testing Web Pages. In this recipe, we will see how to do it according to the object's parent (such as a Frame or WebTable, but can also be any WebElement), which is the container that holds our target TO.

How to do it...

Suppose that we have a reference to an OR TO and need to perform an operation or checkpoint using it and that we know the description of its container object. We can then write the following function that will indicate whether the target TO is the one we were looking for, based on its parent:

Function IsObjectByParent(ByVal obj, ByVal oDicProps)
    Dim bParent, oParent...