Saturday, 15 October 2011

Debugging In QTP

This article explains the procedure to debug the scripts in QTP. Every Automation Engineers should be strong in debugging. Then only we can fix the script issues in a fast manner and complete the scripts successfully.
Here comes the steps involved in debugging.
01. Debugging Configuration: Navigate to Tools> Options > Run tab and make sure that the option "Normal" is enabled. If this options is disabled we can come to know that the Microsoft Script Debugger is not installed. We need to install the script debugger to enable this option.


02.Using Breakpoints: Breakpoints are inserted into script to switch the script from normal mode to debugging mode. We can insert the break point for the selected step by pressing F9 or right click on the step and select "Insert/Remove Breakpoin.." from the context menu. So, the script execution will be stopped on the selected line.
Assume that we have 4 lines of code and inserted the breakpoint on 6th line.So, the script execution will be stopped at 4th line.
Note: One Red Dot will be appeared on the left side of the selected line once the break point is inserted.


03. Enabling the Debug Viewer: Debug viewer is used to watch the values of the variables during execution. So, we should enable the debug viewer.Debug viewer can be enabled by selecting the option View>Debug Viewer.


04. Assume that we have the following code.
          01. Dim a,b
          02. a="This is the debugging code"
          03. b=Left(x,4)
          04. MsgBox b  'Assume that the break point is inserted here.


05.Working with Watch expression tab in Debug Viewer: In this tab we can add the variables a,b in left columns and can see the contents of the variables in right column of each variable. As per above example we can see "This is the debugging code" and "This" for the variables a and b respectively and also length of a,Mid of a also displayed. We can also change the values of each variables by double clicking on it.


06. Working with Variables tab in Debug Viewer: We can see the name and values of all variables that are currently visible in the local scope.As per the above example we can see "This is the debugging code" and "This" for the variables a and b respectively.


07. Working with Command Tab in Debug Viewer: This tab is used to execute the VBScript statements interactively. Select the tab and then type b "changed from command" and press Enter key.. Now navigate to Variables tab and can the value for b as "changed from command".

0 comments:

Post a Comment

 
Back To Top