How to put any user defined function in QTP library? Now this function should become inbuilt function and can be used anytime I use QTP. Is this possible? If yes then how?
NOTE : [This question was asked by Renu]
How to put any user defined function in QTP library? Now this function should become inbuilt function and can be used anytime I use QTP. Is this possible? If yes then how?
NOTE : [This question was asked by Renu]
Yes this possible..
You have to write the function in a note pad and save it in Test settings >resource tab as an attachment.
Then you can call the function in ur program.
You can write as many functions as u can in that note pad nas save.
Thanks
Prasanna
hi friend this is ramu iam happy to answer u r question .first let me explain what is function the actions which are more repeatable for that we are defyining as in function and we are calling that functions very freequently whereever we want . the main advantage of function is code reasubility
to make use define function first of all make one script with function and run it in qtp to find logical errors and copy that script and paste it in notepad file with .vbs extention again come back to qtp and load that script using
executefile"filepath" u can load this file any where i hope u got the answer
if u have any query please consult me
Hi Prasanna,
A very good thing you have mentioned in your above post.
But i don't think this is the reply to the post. The approach you said is "adding a user defined library function or functions to your script."
We can have a library file and we can use it at any time.
But now my concern is how can we make a permanent function like "MsgBox".
We can use it in any script, no need to attach any file.
are you getting me,..
I think there might be some approach for creating any ".dll" file and to register..
I hope people will come up with any idea for this post.
Let me know if i am wrong.
Thanks, Jitu
Hi All,
There is an alternate way to make available a user defined function for all tests (as a build-in function). This approach doesn’t require a function library to be associated to a test. We need not to work with .vbs files and execute or include them in our QTP script either. This is a good approach but could be risky.
We can copy our function definition (in VBScript) to common.txt file in Program Files\Mercury Interactive\QuickTest Professional\dat\BPT_Resources. We may even register this function to a windows or web object. Be careful not to change any other content from the text file. This is a text content, but it contains the definitions of the built-in functions for QTP. Don’t do it if you don’t know VBScript coz if you change any other content from the file knowingly or unknowingly, you should be able to correct the changes. It is better to keep a copy of the original file before you copy your function definition into the file… just in case.
After you copy your function definition, save and close the file. Close QTP and restart it again. Now, your user defined function should be available for all tests as a built-in function.
Lack of WILL POWER has caused more failure than
lack of INTELLIGENCE or ABILITY.
-sutnarcha-
prasanna.sabat ,
If I have a function "test" in a file which saved as myfunctiontest.vbs and loaded to test|Setting|Resource, How do I call the function?
Hi All,
I am new to QTP. I am trying to write functions in QTP. Help me with the basics to write functions.
Thanks
Ameesha
hai friend,
Here is the sample to write a function.
Set obj_WebEdit = Description.Create()
obj_WebEdit ("Class Name").value = "WebEdit"
obj_WebEdit ("name").value= strWebEdit1
obj_WebEdit ("html tag").value="INPUT"
Browser(strBrow1).Page(strPage1).WebEdit(obj_WebEdit).Set strInValue1
1. You should convert the above script as a function.
2. Save the above script with .vbs extension
3. Attach the function in the File->Settings ->Resources
4. Then call the function where ever necessary.
Thanks
Deepa
Arise Awake And Stop Not Till The Goal Is Reached
Yes user defined function in qtp is possible. How we can do that. I will give you one small example. Being on qtp , click file-> new->test->"test". Test will be your file name. Next again file->new->function library->"testfunction.qfl". Next is being on "testfunction.qfl" insert-> "functiondefinitiongenerator" . Inside the function definition generator window, select tab -> function generator and type name of function as "my_sum". From right hand side argument click on "+" symbol and pass arg1 , arg2 by clicking twice in "+" symbol. Click on additional information tab and supply name as "addition function" and click ok to close the function definition generator window. Being on file "test function.qfl -> select file menu-> associate library function with "test"-> click on it. Now open file test->and type as my_sum 1,3 and click on run to execute the script, it will print the result as 4, hence the assumption is my_sum is now become public and it can be associate with any test to get the result. /cheers jayanta