QTP10.com is a new and completely free website that offers help in all the versions of HP QTP (including latest version 10). More importantly, it offers free code for users of HP QuickTest Professioal. This site helps you in learning the basics of QTP and descriptive/advanced programming in (QTP) on various environments like - .Net, Infragistics, Web, Windows, etc.

Note -
This blog is NOT affiliated with HP / Hewlett-Packard in any way. The data/questions come from various sources and we have our own testing questions. I am just another Software Tester like you.

How to Debug custom functions in QTP

Share This Post -

Sponsored Links:

Debugging suggestions include:
1.
Use the suggestions above for debugging a script.
2. Verify the code works when it is not within a function. If the code does not work when it is not in a function in a QuickTest Professional (QTP) script or within a pure VBS script (while QuickTest Professional is not in use), it will not work when it is placed within a function. The following example shows the step by step process of debugging a simple function.

Example:

Function ex_func(obj, txt)
msgbxo obj.Exist
msgboxx txt
End Function

To debug the above function (which has intentional typos), copy the statements into a QuickTest Professional script:

msgbxo obj.Exist
msgboxx txt

If needed, modify any references to a generic object to an actual object:

msgbxo Browser("Browser").Exist
msgboxx txt

Execute the code; debug as needed:

msgbox Browser("Browser").Exist ' corrected typo: msgbxo -> msgbox
msgbox txt ' corrected typo: msgboxx –> msgbox

Copy the corrected code into the function. Verify it works as expected:

Function ex_func(obj, txt)
msgbox Browser("Browser").Exist
msgbox txt
End Function

If needed, modify references to specific objects back to general references:

Function ex_func(obj, txt)
msgbox obj.Exist
msgbox txt
End Function

Verify the function works as expected.
(Optional) Move the function into a function library.

3. If your function is returning a value, the value should be assigned to the function name. This is a VBScript requirement.

Example:
Function examplefunc
examplefunc = "returned value"
End Function
msgbox examplefunc

4. If your function is saved in an external function library, make sure you associate the function library with the test script.

by - Abhishek Nema - http://goo.gl/HUSSo