Skip to main content

HP QTP Tutorial - Chapter 10

1 Debug

In my previous chapter, I discussed about the features available in Resources Menu such as Object Repository, OR Manager, and Associate Repositories etc. This chapter covers the features available under Debug Menu option. This chapter explains the following features available under Debug Menu:
clip_image002

The features under Debug menu are very useful and also frequently used. Although in most of the cases you use Short Keys. We will cover all these features in detail in this chapter.

1.1 Pause

 There could be case when are you running your script and want to pause (remember Pause and Stop are different things), then you can navigate to Debug->Pause. The script will be paused at the current execution step. You can then do your analysis and then continue with your run by clicking on Automation->Run. Alternatively you can also Press F5 or Run button from the tool bar.
clip_image004

 1.2 Step Into

 There are situation in a script which makes call to other Action or Function. While debugging the Test Script, if we want to navigate to called action or function, then use Step Into debug feature. You can use this feature either by navigating to Debug->Step Into or Press F11. This is also very frequently used debug feature of QTP.

 1.3 Step Over

 This is one of the most frequently Debug Feature of QTP. When you are running the script in Debug mode and want to execute each step at a time, then Step Over feature is used. You can either Press F10 (which most test engineer used to do) or navigate to Debug->Step Over.

 1.4 Step Out

 There could be situation where while debugging you went to Called Action or Function using Step Into and now want to come back into Original Action then you can use Step Out to return to your Main Action. You can either Press Shift+F11 or navigate to Debug->Step Out.

 1.5 Run to Step

 You can use this feature when you want to execute the code from start point to a point in between. For e.g. if you have a action having 100 lines of code and you want to execute from Line 1 to Line 50, then you can use Run to Step feature to execute your code up to Line 50. You can do this by putting cursor to Line 50 and navigate to Debug->Run To Step or press Ctrl+F10 or right click on the expert view at line 50 and select Run to Step from Inline menu.
clip_image006

 1.6 Debug from Step

 The debug from step is also a good feature which will do your script execution till the point where you want to start your debugging. For e.g. if a Test Script is having 100 line of code and you want to start your execution from Step 30, then you can choose Debug->Debug from Step at line 30. You can also start from Line 1 depending on your need. This is also a very good feature.

 1.7 Add to Watch

 Add to Watch is a good feature when you want to analyze the value of the variables during the run and then validate your logic etc. You can add the variable in a watch list and do your analysis during debug process. You normally use Add to Watch in combination with Breakpoint, Debug mode. To use this feature select the value that you want to watch and then either press Ctrl+T or navigate to Debug->Add to Watch. As soon as the variable is added for watch you can see the value in Debug Viewer. See the below screen shot:
clip_image008
This is a very good tool for debugging the test script. As you can see that there are 3 tabs in the debug viewer - Watch, Variable and Command. The usage of these 3 tabs is mentioned below:
Watch – In this tab you can see the value of the variable which you have added to watch. It will show name of the variable, its value and type (what type of variable it is). The value on other 2 fields will be seen when you are in Debug mode.
Variables – In this tab you can see the value of all the variables in the current test script. You do not add it to see the value. This is the default feature of QTP which display the detail of all the variables used in the script. The values are visible only in Debug mode.
Command – In this tab you can overwrite the value of any variable during run time but in debug mode. This is a very handy debug utility and when used appropriately is going to be a boon for test engineers. For e.g. if I want to override default value of a variable during run time then I can use Command tab to override such value.

 1.8 Breakpoint – Insert/Remove/Clear

 Breakpoints are the point where script execution will be halted for further debugging. This is also a very handy debug utility and very frequently used by Test engineers. To insert a break point in a script you just place your blinking cursor on that line of code and either Press F9 or navigate to Debug->Insert/Remove Breakpoint. As soon as you press F9 you will see a red dot circle on the line of code in the test script
.clip_image010
To clear the breakpoint you have to again press F9 on that line of code. There could be instances when you want to clear all the breakpoints in the test script, then you can navigate to Debug->Clear All Breakpoints or press Ctrl+Shift+F9

 1.9 Breakpoint – Enable/Disable

 You can also disable breakpoints instead of removing it. This is needed when you want to execute your script in complete but still want to keep your existing breakpoints. In that case instead of clearing the break points you can disable the breakpoint. You can either disable all breakpoints or specific breakpoints. To disable all break points, navigate to Debug->Enable/Disable All Breakpoints

clip_image012
A disable breakpoint will be shown as a red bordered circle.
To disable an individual break point you can navigate to breakpoint line of code and press Ctrl+F9 or navigate to Debug-> Enable/Disable Breakpoints

 2 References

 Quick Test Professional Tool.

 3 Additional information

 You can email me on Sachin.vasudha@gmail.com with any query.

 4 What Next?

 In my next Chapter I will explain the features of Tool Menu options.

Comments

momna said…
I had been searching such a understandable link where the 'Debug' menu features defined in simple words. Nice work.

Cheers :)
momna said…
I had been searching such a understandable link where the 'Debug' menu features defined in simple words in order to conduct a session in my company. Finally, I'v found that link. Nice work.

Cheers :)

Popular posts from this blog

Mantis - Defect Management Tool - User Guide

Introduction This white paper contains information related to an open source defect management tool called Mantis which is freely available for managing all your defects. Where to Download One can download the latest version of Mantis from http://sourceforge.net/project/showfiles.php?group_id=14963 Download the “mantis-stable” and then “mantis-x.y.z.zip”.1.1 PRE-REQUISITE Operating System Windows 2003 Server, MacOS, OS/2, Linux, Solaris Database MySQL database 3.23.2 and higher Software PHP 4.0.6 and higher Application Server Apache 1.3, Apache 2.0.54, IIS 6.0 with Web Services Extension Browser IE6 and above, Mozilla Firefox STEPS FOR INSTALLATION – FOR WINDOWS MySQL Installation Install MySQL by downloading it from http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-gui-tools-5.0-r6-win32.msi/from/http:/www.mirrorservice.org/sites/ftp.mysql.com/ . Please follow the below mentioned steps while installing MySQL: (Please remember the password for “root” account...

Why to do Software Testing?

Regardless of the limitations, testing is an integral part in software development. It is broadly deployed in every phase in the software development cycle. Typically, more than 50% percent of the development time is spent in testing. Testing is usually performed for the following purposes: To improve quality. As computers and software are used in critical applications, the outcome of a bug can be severe. Bugs can cause huge losses. Bugs in critical systems have caused airplane crashes, allowed space shuttle missions to go awry, halted trading on the stock market, and worse. Bugs can kill. Bugs can cause disasters. The so-called year 2000 (Y2K) bug has given birth to a cottage industry of consultants and programming tools dedicated to making sure the modern world doesn't come to a screeching halt on the first day of the next century. [Bugs] In a computerized embedded world, the quality and reliability of software is a matter of life and death. Quality means the conformance to the ...

Is BCI (Brain Computer Interface) a road to immortality?

What is a Brain-Computer Interface? Brain-computer interface is a technology which can read your mind and display it on a device - a mobile, laptop or TV screen. It means what data is being carried by our billion neurons are prone to hack.  When combined with other mechanical devices, can also be used to control the device.  So in future, if you want to switch on your TV or light, you just have to think and that's all.  Google and Alexa home will be replaced by BMI controlled devices.  I am not an expert in this field but based on my research and analysis, I can predict that when BMI tech will get matured, the human can do brain to brain talk and many other magical things - in future Telepathy will be a day to day affair. BCI can give you all kind of experience from the comfort of your home.  You can go on vacation without leaving your bedroom. You can have romantic experience without having a partner and many more such experiences. ...