UFT/QTP – Debugging

Debugging is the process of locating and fixing errors in the program code. After you create a test, you should check that it runs smoothly, without error syntax or logic. Set the breakpoints in the program to stop program execution and to isolate defects.

There are various ways to perform debugging using break points in QTP. Break Points can be inserted just by pressing “F9” or by using the Menu option “Run” → “Inserting/Removing Break Point”.

After Inserting the Break point the “Red Colored” Dot and the line will be highlighted in RED as shown below:
QTP BreakPoint Script

How to Debug?

Step 1 –  Add/Delete Breakpoint

  • Click a step or line in the test where you want the run to stop
  • choose “Run > Insert/Remove Breakpoint”
  • To remove a single breakpoint click a line in your test or breakpoint symbol and choose  “Run > Insert/Remove Breakpoint”
  • To remove all breakpoints choose “Run > Clear All Breakpoints”

Break Point Options:

Various Options in Break Point can be accessed by Navigating ‘Run’ Menu

Shortcut Description
F9 Insert/Remove BreakPoint
Ctrl+F9 Enable/Disable BreakPoint
Ctrl+Shift+F9 Clear All BreakPoint

Step 2 –  Start running the test, Control will stop at first break point encountered

Step 3 –  Select “View > Debug > (Viewer Option like Watch, Local Variables)” to display debug viewer as shown below. This is view the values of variables and watch the results of expression and also to execute commands.
QTP BreakPoint Viewer

  • Output – This Tab displays all the Output of the Print Statements.
  • Watch – This Tab displays the current values and types of variables and VBScript Expression.
  • Local Variables – This Tab displays the Output of the Local Variables
  • Command – Enables you to run VBScript commands in your paused run session

Step 4  – Run line by line

Method Shortcut Description
Step Into F11 Used to execute each and every Step. Steps into the Function/Action and executes line by line. It pauses on each line after execution.
Step Over F10 Used to Step over the Function. Step Over runs only the current step in the active document.
Step Out Shift+F11 After Step Into the function, you can use the Step Out command. Step Out continues the run to the end of the function and then pauses the run session at the next line.

Step 5 – Check the value of the variables in the Debug Viewer Pane
Step 6 – Modify the Value of variable using the command Tab.

Leave a Reply

Your email address will not be published. Required fields are marked *