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

Synchronizing a test with a web page loading


An essential requirement from any automated test script is that it must synchronize with Application Under Test (AUT). This is especially true for GUI automation, because the test script actually attempts to emulate the actions that a human user would perform on the application's front end. Hence, it is of utmost importance to take care that operations on a page are carried out when the controls are fully loaded and ready to accept inputs.

How to do it...

All web classes, Page, WebEdit, WebButton, Image, and so on, provide an attribute that indicates the state of the element. This attribute is readystate, and its value ranges from 0 (uninitialized) to 4 (complete). So basically, to synchronize our script with the full loading of a web element, we need to wait until its readystate attribute reaches the value of 4.

The following generic function accepts an element and a timeout period, and it waits until the element reaches the load complete state...