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.
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...