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 |
Is qtp supports uni-code?
Types of properties that Quick Test learns while recording?
why was automation used in the project?
How we can test a Frame in a web page?
1. What is the difference between Keyword and function in the keyword driven framework? 2. How do you associate Keywords to the script ?
How to count the no of objects in XML file(QTP)
Hi guys, Our company has started to automate testing and started using the tool QTP.Iam new to QTP and I have the following questions to ask. Would appreciate if anyone could give me a hand on this and explain things in a detailed way. [1] Bugs outside checkpoints: I know that I can easily make the QTP do what I want inside the application. Also, I know that I can insert some checkpoints and that the qtp will notice if those conditions are not met. However, there are bugs and problems that might not be connected to a checkpoint (system crash, database error, losing session/logout etc.); how can I make sure that the QTP will notice such problems as well and flag a test as failed. [2] How to tell the QTP that when a particular statement is "false",it should flag it as, test failed and show in in the test report. In short how to tell the qtp that a test is false from the script so that it shows it in the report For Eg:- if(true) test passed // how to instruct qtp else test failed // how to instruct qtp [3] Test script portability: we are having several environments; If I record a test on User Interface, obviously, the qtp will save the URL; however, how can I make the qtp run the tests so that the url is provided dynamically. Is there a possibility to parameterize the web server.Is this the way to do it.I dont know? [4] Test management: How do I manage the tests? I guess we will be doing it in Quality Center, yet, it’s not perfectly clear to me how we will be doing that. [5] Running scheduled test sets: How do I group tests to a certain test set? How can I make this test set run at a predefined time? [6] Test maintenance: What do we need to do beforehand in order to enable for easy test maintenance, meaning small adjustments in tests? [7] Reports: What kind of reports on test results are available (either QTP or Quality Center)? Thanks in advance and hoping for an answer. Jen
How to find operating system information using the qtp script?
in flight reservation ex once u login, u go into next window where we hav an option of new, open and help etc.. how to fetch those options and to go to respectiv tab accordingly using qtp.. plz let me knw answer for tis as early as possible. Thanks in advance... asha
How to execute the test cases using QTP. i.e What is the use of QTP while execution
Hi all, I am New to QTP . I am Now in critical situtaion. I want to know How to create our own object respository for our application. please say the answer with example.
Is QTP Supports SWT applications? If yes, can you write a sample script for opening a new package in eclipse.