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

Accessing web elements through DOM


Although UFT provides a rich interface that encapsulates the most common operations required to manipulate web elements (for example, click, double-click, set, select, and so on), it has some limitations. For instance, UFT does not give us an obvious way to verify the style of the text. In such a case, we will refer to the Document Object Model (DOM) to get access to the native methods and properties of the elements. Another situation that would justify such usage would be when the performance of the test run is hindered when a huge amount of elements needs to be processed. For example, processing a table with lots of rows and columns through UFT's WebTable interface takes much longer than accessing these same elements through DOM. In this recipe, we will see how to get the style of an element and how to get a collection of elements with a particular HTML tag.

How to do it...

Proceed with the following steps:

  1. First, we will get a reference to the document...