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

what will be there in keyword view and expert view?

2 Answers  


What r the different type of reports generated in Quality Center?

1 Answers   TCS,


How to find local host name using QTP?

6 Answers  


what are inputs for automation?

3 Answers  


How the smart identification is used in real time?Please explain with an example

0 Answers   Wipro,






When testing a web application, the url for each page changes, so using QTP how do u handle this scenario. If anyone knows please answer in detail about the whole procedure. Thanks a lot.

3 Answers  


What is text/text area checkpoint?

0 Answers  


How to Parameterize Object repository in QTP?

6 Answers   Cognizant, IIBM,


Tell me the situations where we will use Data Driven?

2 Answers  


How many types of parameters are there in QTP and what are they?

2 Answers  


Is it possible to call from one action to another action in qtp?

0 Answers  


How we can merge the object repositories?say if we have 2 or 3 object repositories then how we can merge them?Is there any option in QTP to merge the object repositories?

2 Answers  


Categories