https://www.qatechies.com

HP QTP Utility Statements : RegisterUserFunc Statement

technical-concept-uft

HP QTP Utility Statements : RegisterUserFunc Statement


Welcome to this post! – ” HP QTP Utility Statements :RegisterUserFunc Statement”.

If you are looking for HP UFT, QTP utility statements and their usages, then you are at right place. This post “HP QTP Utility Statements : RegisterUserFunc Statement” consists of concept discussion and usage discussion. Go ahead and enjoy reading…

This discussion will help you prepare well if you are going for the interview and can help you if you need the function to be used in your project test suite.

 

RegisterUserFunc Statement

Abstract

The RegisterUserFunc statement is used to register the previously registered function or method. This method could have been used for some special requirement. The statement in itself falls under the category of utility statements and not utility objects.

Remember there is a difference between utility statements and utility objects.

Before we dig down deep into the usage let’s quickly visit some general questions.

In the interview usually, you might be questioned in different ways like:

  1. How to set custom method for any control class?
  2. Can you use the RegisterUserFunc statement by calling some other methods in external function file?
  3. What are the objects and parameters of RegisterUserFunc statement?
  4. Is RegisterUserFunc an object or statement?

 

Discussion

This is the most used and discussed statement in QTP. The RegisterUserFunc statement instructs enables you to add new custom methods to test object classes or change the behavior of an existing test object method during a run session.

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

If the specified custom method name does not already exist for the test object class, it becomes a new method for the test object class.

 

Point to Note here:

  1. If you register a function within a reusable action, it is recommended that you de-register the method at the end of the action.
  2. You cannot register a method for a QuickTest reserved object (such as Recover, Reporter, and the other objects listed in the Utility Objects.
  3. The custom method name cannot contain spaces.
  4. The function can be located in your action or in any library file associated with your test or component.
  5. 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).
  6. If the custom method name is a defined QTP method for the test object class, your definition (temporarily) overrides the existing functionality of the specified method.

Syntax

RegisterUserFunc TOClass, MethodName, FunctionName, SetAsDefault

 

Let’s see the parameters and their usage description for this statement:

Argument Type Description
TOClass String The test object class for which you want to register the method.
MethodName String The method you want to register.
FunctionName String The name of your user-defined function.
SetAsDefault Boolean This is Optional. Indicates whether the registered function is used as the default operation for the test object.

Default = False

 

Example

Suppose that the Web page contained a Country edit box, and by default, the box contained the value USA. The following example registers the Set method to use the MyCustomSet function in order to report the default value of the edit box to the run results before the new value is entered. After using the registered method in a WebEdit.Set statement for the Country edit box, the UnRegisterUserFunc method is used to return the Set method to the standard QuickTest functionality.

 

'RegisterUserFunc  example

Function MyCustomSet (obj, x)

	dim y

	y = obj.GetROProperty("value")

	Reporter.ReportEvent micDone, "previous value", y

	MyCustomSet=obj.Set(x)

End Function

RegisterUserFunc "WebEdit", "Set", "MyCustomSet"

Browser("MercuryTours").Page("FindFlights").WebEdit("Country").Set "Africa"

UnRegisterUserFunc "WebEdit", "Set"

 

You might also want to check UnRegisterUserFunc Statement

 

This brings us to the end of our discussion on “HP QTP Utility Statements : RegisterUserFunc Statement”.

 

I really hope you have enjoyed reading this short post. If you have any doubt on this please feel free to add your comment below.

 


Other Utility Statements:
UNREGISTERUSERFUNC REGISTERUSERFUNC
SETLASTERROR GETLASTERROR
INVOKEAPPLICATION EXITTEST
EXITACTION EXITACTIONITERATION
DESCRIBERESULT EXECUTEFILE
EXITCOMPONENT EXITCOMPONENTITERATION
LOADANDRUNACTION PRINT
WAIT EXITTESTITERATION
LOADFUNCTIONLIBRARY CALLSERVICETEST
OBSOLETE MANUALSTEP
RUNACTION  

And if you like to read more on UFT or QTP Technical Interview Questions please follow below links: 

UFT Technical Interview Questions – Set 1

UFT Technical Interview Questions – Set 2

How to Download Resource From QC\ALM?

How to Upload Resource To QC\ALM?

 

Or if you prefer General Interview Questions please follow below links:

UFT General Interview Questions – Part 1

UFT General Interview Questions – Part 2

 


If you would like to keep track of further articles on UFT (QTP). I recommend you to SUBSCRIBE by Email and have new UFT articles sent directly to your inbox.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

advanced-floating-content-close-btn
https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5034726663464946 (adsbygoogle = window.adsbygoogle || []).push({});
advanced-floating-content-close-btn 
*************************** Do you want to learn TOSCA? Do you want to excel in Career? Try my New Courses: 1. Tricentis Tosca and Working with Excel   2. Tricentis Tosca and UI Automation Great News!!   Price has been slashed down for limited period of time.So Hurry!!! Click The Shown Links and Enjoy Learning. ***************************
 
error: Content is protected !!