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
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 |
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 |
Answer / rentalavdml
Its used for "overriding" an existing function
| Is This Answer Correct ? | 7 Yes | 4 No |
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 |
how to invoke the web application through script in qtp
With out using the task manager,how to close the application using vbscript and what is the statement?
How u prepare Test result summary in QTp?
How to create Userdefined Function.Please write the steps ans also provide example where exatcly we use it.
what is the Command used to start the QTp from Run.(start-> Run)
what is virtual object?
What are the enhancements u did after recording ur script?
how to acess a test in RSA?
If a button named "CLICK" is recorded in low level recording mode , what will be the values stored for "name" property of that button in object repository ?
While creating Recovery Scenario for Pop-up window..In 'Recovery operation' we have to call a function. Can u tell me that function.
4 Answers Alcatel-Lucent, Ordain Solutions,
Give a comment on Regular Expressions using QTP?
Have you ever written a compiled module? If yes tell me about some of the functions that you wrote.