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

Loading and creating XML documents (XMLUtil)


The XMLUtil object is a utility that provides methods to do the following:

  • Create an XML wrapper

  • Load an existing XML file to an XML wrapper

Similar to other wrapper classes provided by UFT (such as those for Test Objects), it is convenient to simplify the usage of XML data via code. It provides an array of methods that cover the most frequently used functions of XMLDOM. Of course, if one needs specific functions not provided by the wrapper, it is always possible to recur to the XMLDOM or LINQ object model (which is not covered in this book).

For example, to get a specific node by ID, we shall use the native method GetElementByID.

Getting ready

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

How to do it...

In the Action object of the test, write the following code:

Set xml = XMLUtil.CreateXML()

The xml variable is set to a new instance of the MicXmlData class (see a more detailed description in the following screenshot). The instance...