What is the use of "Registeruserfunc" when should we use
it?
Note:Please do not copy paste the date from QTP help.
I tryed it.But I don't Understand where should we use
exactly.

Answers were Sorted based on User's Feedback



What is the use of "Registeruserfunc" when should we use it? Note:Please do not copy p..

Answer / arun

Its used for "overriding" an existing Method [ex: click).
You can define your own method also.

If you want to try it do the following simple example.

Goto function library and save the below code.

Public Function func
Dialog("Login").WinButton("OK").Click 'for what
operation
End Function
RegisterUserFunc "WinButton", "myfunc", "func"

Now you have registered this function with the object
winbutton.

now associate this function lib to a new test
so the test should have code like this....

SystemUtil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program
Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set "arun"
Dialog("Login").WinEdit
("Password:").SetSecure "4c9adb5be66f637242d3941587f3a0762c6
e5350"

Dialog("Login").WinButton("OK").myfunc
Window("Flight Reservation").Close

now run the test u see the difference and the use of
register user func

Note: To run this test, you should have all the objects
saved in your object repository


Regards
praveen and arun

Is This Answer Correct ?    13 Yes 2 No

What is the use of "Registeruserfunc" when should we use it? Note:Please do not copy p..

Answer / anish pillai

RegisterUserFunc in QTP can be used for both Method
Overriding as well as Method Reuse.

In method overriding, we can override the default
implementation of the function and replace with a new custom
implementation. For example, we can create a function, say
fnClick, which will not only click on an element, but it
also first verify if the element we want to click exists and
is enabled.

In method reuse, we can create a function which we can bind
with multiple controls & then use this function for all
these controls. For example, we can create a function
fnClick, which can be used to click on a button, on a link
on an image and so on. Refer below link for more details -

http://www.automationrepository.com/2011/12/how-to-achieve-method-overriding-and-reuse-using-registeruserfunc-in-qtp/

Is This Answer Correct ?    8 Yes 1 No

What is the use of "Registeruserfunc" when should we use it? Note:Please do not copy p..

Answer / rentalavdml

Its used for "overriding" an existing function

Is This Answer Correct ?    7 Yes 4 No

What is the use of "Registeruserfunc" when should we use it? Note:Please do not copy p..

Answer / rajeev

We are using this method to register an user defined function to QTP so that tool will display the registered user defined function in the drop down list directly like when we are using the inbuilt functions.
For example if we are preparing the script by using cint,cdbl,time,date functions etc... these functions are visible in drop down list .


RegisterUserFunc:- We are using this method to register the user defined function for particular class in QTP.
Syntax:- RegisterUserFunc,"ClassName","Function Name","Method Name",True
Example:-
Public function ButtonEnabled(Obj)
var= Obj.GetRoProperty("Enabled")
If var="True" Then
msgbox "Pass"
else
Msgbox"fail"
End If
End Function

Navigation:- Prepare the user defined function > like above in QTP > Copy the function and paste it in notepad > save as .vbs file > associate the .vbs file to the QTP > Prepare the test script like below
Dialog("Login").WinEdit("Agent Name:").Set "rajeev"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").ButtonEnabled("cancle")
Dialog("Login").WinButton("OK").ButtonEnabled("OK")

Is This Answer Correct ?    3 Yes 3 No

What is the use of "Registeruserfunc" when should we use it? Note:Please do not copy p..

Answer / rayudu

Can you please explain with examples

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More QTP Interview Questions

Hi, Can anyone please tell me how to connect the QC with QTP using QTP script? Thanks in advance

0 Answers  


what is the use of Browser.sync()

2 Answers   NIIT,


difference Between Call Run action and copy of action?

3 Answers   Quest,


How to integrate the qualitycenter with qtp

0 Answers   Wipro,


If there r 1000 test scripts that were written. If a change to any functionality is to be made then how can we know in which script is this functionality existing.

4 Answers   iGate,






DEFECT LIFE CYCLE,WHO PUT THE STATUS AS OPEN

4 Answers   IGT,


What is the Obect Repository type, we use in Automated Testing..in Real time.. Pls anybody can give the answer.. Thanks in advance...

5 Answers   Navis,


Discuss QTP Environment.

1 Answers  


how to check URL using QTP? write vb script with descriptive programm only?

1 Answers   Syntel,


What is the difference in the global and action sheet in qtp?

0 Answers  


What is throw object?

1 Answers  


QTP is used better in which type of application Web based application or desktop application

3 Answers  


Categories