Relevant for: GUI tests and components
When you register a method using a RegisterUserFunc statement, your method becomes a recognized method of the specified test object class for the remainder of the run session, or until you unregister the method.
If your method overrides a UFT method, unregistering the method resets the method to its normal behavior. Unregistering other methods removes them from the list of methods supported by the test object class.
For task details, see Unregister the function - optional.
In certain situations, you must pay special care when unregistering user-defined methods.
Unregistering methods is especially important when a reusable action contains registered methods that override UFT methods. For example, if you do not unregister a method that uses a function defined directly within a called action, then the calling test will fail if the registered method is called again in a later action, because it will not be able to find the function definition.
If you register a method within a reusable action, you should unregister the method at the end of the action (and then re-register it at the beginning of the next action if necessary), so that tests calling your action are not affected by the method registration.
If the registered function was defined in a function library, then the calling test may succeed (assuming the function library is associated with the calling test). However, unexpected results may be produced as the author of the calling test may not realize that the called action contained a registered function, and therefore, may use the registered method in later actions, expecting normal UFT behavior.
You can re-register the same method to use different user-defined functions without first unregistering the method. However, when you do unregister the method, it resets to its original UFT functionality (or is cleared completely if it was a new method), and not to the previous registration.
For example, suppose you enter the following statements:
RegisterUserFunc "Link", "Click", "MyClick" RegisterUserFunc "Link", "Click", "MyClick2" UnRegisterUserFunc "Link", "Click"
After running the UnRegisterUserFunc statement, the Click method stops using the functionality defined in the MyClick2 function, and returns to the original UFTClick functionality, and not to the functionality defined in the MyClick function.