Global JavaScript Methods and Utility Methods

As part of the toolkit support set, you design JavaScript functions that UFT One calls. Your JavaScript functions can call global methods and utility methods that UFT One provides. The global methods are provided as JavaScript functions in the common.js file. The utility methods are exposed by the _util object.

The _util utility object exposes the following methods that you can call in your JavaScript functions:

  • Alert (message). Opens a modal message box displaying the specified message.

  • GetBrowserType / GetBrowserVersion (). Returns the name or version of the browser that is currently running the control.

  • LogLine (text, severity, Id, category). Adds an entry to the Microsoft Windows event log (which you can view using the Event Viewer), or for Chrome, adds an entry in the Chrome Console. Use this method to help you analyze the performance of your support set or debug its functionality.

    For more information on using the Event Viewer to debug your toolkit support set, see Using the Microsoft Windows Event Log.

  • Record (method, arrParams, delay). Adds a step to the test and adds a test object to the object repository if it is not already there. Use this method in a JavaScript function that records a step in a test after an event occurs on a control. For more information on developing support for recording, see Implementing Support for Recording.

  • RegisterForEvent (element, eventName, handler, [HandlerParam]). Registers to listen for a specific event on a specific Web element. Use this method in a JavaScript function that controls listening to events to support recording. You can also invoke it from event handlers. For more information on developing support for recording, see Implementing Support for Recording.

  • Report (status, method, arrParams, details). Adds information about the results of a step to the run results. Use this method in a JavaScript function that performs a step on a control. For more information on developing support for running tests, see Implementing Support for Test Object Methods.

  • Wait (milliseconds). Suspends execution for the number of specified milliseconds.

     

The most commonly used functions from common.js are:

The common.js file also contains variables with preset values that you can use as constants in your code.

The common.js file is located in the <Extensibility Accelerator installation folder>\bin\PackagesToLoad folder and the <UFT One installation folder>\dat\Extensibility\Web\Toolkits folder.

For more information on these methods and constants, see the API Reference.