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