RegisterUserFunc Statement

Description

Enables you to add new methods to test object classes or change the behavior of an existing test object method during a run session.

When you use this statement, UFT One uses your user-defined function as a method of the specified test object class for the remainder of the run session, or until you unregister the method.

If the specified method name does not already exist for the test object class, it becomes a new method for the test object class. If the method name is a defined UFT One method for the test object class, your definition (temporarily) overrides the existing functionality of the specified method.

For more details on user-defined functions, see the Micro Focus Unified Functional Testing User Guide.

Syntax

RegisterUserFuncTOClass, MethodName, FunctionName, SetAsDefault

Argument

Type

Description

TOClass

String

The test object class for which you want to register the method.

You cannot register a method for a UFT One reserved object (such as Recover, Reporter, and the other objects listed in the Utility Objects section of the Micro Focus UFT One Object Model Reference for GUI Testing).

MethodName

String

The method you want to register. The method name cannot contain spaces.

FunctionName

String

The name of your user-defined function. The function can be located in your action or in any library file associated with your test or component.

SetAsDefault

Boolean

Optional. Indicates whether the registered function is used as the default operation for the test object.

Default = False

Note: When you select a test object in the Keyword View or Step Generator, the default operation is automatically displayed in the Operation column (Keyword View) or Operation box (Step Generator). For more details, see the Micro Focus Unified Functional Testing User Guide.

IMPORTANT

  • A registered method applies only to the test or library file in which you register it (or to any tests calling an action containing a RegisterUserFunc statement).

  • For tests, if you register a function within a reusable action, it is recommended that you unregister the method at the end of the action. (See UnregisterUserFunc Statement.)

  • UFT One clears all function registrations at the beginning of each run session.

  • When UFT One runs a registered method, it sends the test object as the first argument. For this reason, any user-defined function that you register as a test object method must have at least one argument, which receives the test object.

  • If you register a user-defined function to override an existing test object method, then after the test object argument, the function must have the same number of arguments as the method it overrides.

 

See also: