Debugging scripts :
Debugging suggestions include:
1. Use the Watch Expressions Tab in the Debug Viewer pane to display the values contained in variables
2. Step through the script one line at a time
3. Use the msgbox function to pause the test and display values contained in variables or retrieved from the application.
txt = Window("Notepad").WinEditor("Edit").GetROProperty("text")
4. If the replay error is related to not being able to identify an object, determine which object is causing the problem (the error can be from a parent object). You can use the .Exist method with the msgbox function to do this.
Once you know which object in the hierarchy is causing the problem (the object that returns "false"), you can work to resolve the issue.
5. If an object class method (one of QTP’s built in methods) is failing, you can use the GetLastError and DescribeResult methods to get additional information on the error.
By default, QTP is set to pause the script during replay and pop up a message box with the error. This setting can be modified on the Run tab of the Test Settings dialog (Test -> Settings).
The GetLastError statement returns the error code of the most recent error. You can use this statement together with the DescribeResult Statement
Error An integer value representing an error
on error resume next
' Make sure the Notepad window is not visible during replay (minimized)
x = GetLastError
msgbox( DescribeResult(x) )
If QTP is not set to pop up a message box on an error, the first line in the example is not needed. If an error message box appears, click <Skip> to continue with the next line in the script. The message box will appear with the results of the GetLastError statement.
6. Define specific sections of the script to run. Use breakpoints and the Run from Step replay option (Test -> Run from Step) to run your script in these sections. For additional information, refer to the following articles:
7. Check the syntax of the statements in your script. Make sure the VBScript code (in the Expert View) matches the expected format. Refer to the QuickTest Object Model Reference for the syntax of QTP methods and statements. For syntax information on VBScript functions, refer to the online VBScript Reference (both documents are accessed by selecting Help –> QTP Help).
8. If your script contains calls to external reusable actions, make sure the calls were inserted correctly.
If a replay error occurs in a reusable action, you will need to open the script containing the original action in order to debug it.
The above are just a few options that you can use to debug a test. The best process to follow for debugging is to isolate the problem and work on resolving it. Test your script in portions to narrow down the area that is causing the problem. Then use the above suggestions try to determine why the problem is occurring.
by - Abhishek Nema - http://goo.gl/HUSSo