Debugging is the process of locating and fixing or bypassing bugs in computer program code.Before starting debugging in QTP,We need to install Microsoft debugger for debugging. This can be done during QTP Installation.
Below are the options available in Debug Menu and will discuss the same in detail:
Pause:
To detect and
isolate defects in a test or function library, you can control the run session
using the Pause command. This will pause the test run and you can check
for state of objects, and values in variable at the moment of pause to get the
issue. You can temporarily suspend a run session by choosing Debug >
Pause or clicking the Pause button. The Test execution will resume
if we Press F5 or Run.
Step Into :
While navigation
into a function definition from the function called in script. We can use Debug>Step
Into or Press F11 or click on Step into button. Using Step Into, we can debug
in the function called in script and run each step line by line in the
function.
Step Over:
Step Over does
debugging line by line in the script, but does not debug into a function called
within script, but executes the function as a step and moves to next step in
the Test. We can use Step Over using F10 Key or Debug>Step Over or icon for
Step Over in the QTP IDE.
Step Out:
Suppose we have
step into a function as explained in Step To, and wants to come out of the function
or Action, we use Step Out Option. We can use Step Over using shift + F11 Key
or Debug>Step Out or icon for Step Out in the QTP IDE.
Run To Step:
You can instruct
QTP to run from the beginning of the test or action or from the current
location in the test and to stop at a particular step. This is similar to
adding a temporary breakpoint to a step.
To select Run
to Step, Insert your cursor in the step in which you want QuickTest to stop the
run and choose Debug > Run to Step or press Ctrl+F10
Debug from Step
You can instruct
QuickTest to begin your debug session from a particular step instead of
beginning the run at the start of the test or action. Before you start
debugging from a specific step, make sure that the application is open to the
location.
To debug a test
from step, Insert your cursor in the step where you want QuickTest to start the
run and choose Debug > Debug from Step.
Using BreakPoints in QTP:
We can use
breakpoints to suspend a run session and inspect the state
of your application or mark a point from which to begin
stepping through a test or function library.
Breakpoints are
applicable only to the current QuickTest session and are not saved with the
tests.
Test execution
pauses at the step where we provide breakpoint. A breakpoint can be inserted
using Debug >
Insert/Remove Breakpoint or clicking Insert/Remove Breakpoint button or pressing F9 key on the step.
To
enable\disable a breakpoint,i.e enable a checkpoint if disabled below or vice
versa, Press Ctrl + F9 or select Debug > Enable/Disable Breakpoint
We can enable
disable all breakpoint by selecting Debug > Enable/Disable All Breakpoints or click the Enable/Disable All
Breakpoints button.
Debug Viewer in QTP:
We can use debug Viewer in QTP to view, set, or
modify the current value of objects or variables in your test or function
library, To view Debug Viewer, Choose View
> Debug Viewer or click the Debug Viewer button.
Below are the tabs in Debug Viewer:
Watch Tab
This is used to
view the value of any variable or an expression in the test. To add an
expression, Click the
expression and choose Debug > Add to Watch.
Variables Tab
QTP
automatically displays the current value of all variables in the current action
or function in the Variables tab—up to the point where the test or function
library is stopped or paused. We can change value of a variable manually also
in variables tab. This will be reflected in test.
Command tab
This is to
execute a line of script to set or modify the current value of a variable or
VBScript object in your test or function library.