Skip to main content

HP QTP Tutorial Chapter 8

1 Automation

In my previous chapter, I discussed about the features available in Insert Menu, QTP Checkpoints and usage of Output Value features. This chapter covers the features available under Automation Menu option. This chapter explains the following features available under Automation Menu:
clip_image002[4]

The features under Automation are very frequently used when you need to do the scripting. You can control your recording, run your test, and update your Test. We will cover most of the features in detail in this chapter.

 1.1 Record

Recording features work in 2 ways. One when you are starting a new test and want to start recording for generating the Test Script and when you want to enhance existing script for new features in your AUT. I will explain both the mode. We will start with Record for New Test. When you are starting with New Test, and about to start with recording of your scenario, you have to either press F3 or navigate to Automation=>Record. As soon as you have initiated either of these commands, you will see a Record and Run Settings Dialog (I will discuss about Record and Run Settings in Chapter 9). As of now you need to know basic things which I am explaining below:
clip_image004[4]
Based on your need, you have to provide the settings for your recording so that AUT script can be generated as you navigate or explore your AUT. You are seeing 2 Tabs – Web and Windows which are default. You might see other Tabs if you have different application such as SAP, Siebel, PeopleSoft etc. Based on your need, you have to choose either of the options. For our sake, we will choose “Record and Run test on any open browser”. But before that we will ensure we do not have any other browser opened with other application or website. When we choose this option we are going to open only the application under test. After your settings, you need to click OK. As soon as you click OK, you are into recording mode and whatever action you are performing on AUT, all these actions are getting logged or recorded. You can see the script or steps generated automatically in Keyword or Expert View. Another important point is that of Analog Recording and Low Level Recording which only get enabled when you start your recording. I will discuss these 2 additional types of recording in later part of this chapter. If your “Capture Screen Images while Recording” is enabled, then you can also see the recorded screen shot in Active Screen section. At any point of time, press F4 to stop the recording.

 1.2 Run

As part of scripting and to do unit test and debugging, you need to run your script. You can do so by opening the Test Script and then either press F5 or navigate to Automation=>Run. When you press F5, you see a Run Dialog box having 2 tabs – Result Location and Input Parameters (More detail will be covered in Chapter 9). As of now let the Result location set as Temporary without making any changes. After you click OK, your test execution will get started and you can either Pause your test- press PAUSE key or stop by pressing F4. Once your test completes, you can see the Test result after execution.
clip_image006[4]

 1.3 Stop

As the name suggests, whenever you want to completely stop your test execution, you can press F4 or navigate to Automation=>Stop. Please remember this option is enabled only when your Test is in execution mode. You can also press F4 when your AUT is taking too much time to respond.

 1.4 Run Current Action

You might come up with cases, while you are doing debugging of the script where in you just need to run a particular action in your Test Script. I am considering that you are having more than 1 action in your script. What to do in such a scenario? Well, QTP have solution to this, you need to select the action which you want to execute and then click Automation=>Run Current Action. This will execute the current action only but if current action have further reusable nested actions, then those will also get executed as part of run. But you always have option to PAUSE or STOP – F4.

1.5 Run from Step

When you are writing your script, there might be certain situation where you want your script to be executed from a particular line of code. In such cases you need to place cursor on that line and choose Run from Step. You can also right click on that line, and choose Run from Step. The shortcut key is Ctr+F5. I will say, that this is also very frequent command which you will be using when you are developing your script, debugging your script or enhancing your script. This command will ignore all the script above the line from where you have initiated the Run from Step. For e.g. See below:
clip_image008[4]
If I have to run the code from line 4, I should place my cursor on line 4 and then either Press Ctr+F5 or Rt Click=>Click Run from Step or Goto Automation=>Run from Step.

Note: When you have loop or conditional statement in your code, and you are trying to run from line which is inside loop or conditional statement, then your script will return error related to syntax, so please pay attention while executing your code from specific line and ensure that cursor is placed at right place in case of loop and conditional statement.

 1.6 Analog & Low Level Recording

Analog Recording and Low Level Recording are workaround options when normal recording fails to solve am automation business problem. For e.g. If you are working on Legacy Application and HP QTP does not recognize the action being performed, or you are dealing with BITMAP application, in such scenario, you can choose to record your test in Analog or Low Level Recording mode. I will explain the difference between these 2 in below paragraph.
Analog recording is needed when I am having a scenario where I need to digitally draw my signature for future reference or I need to draw unique image as passcode. Whenever operation which can be accomplished by using mouse movement and we want to capture the exact movement of mouse, then we will enable Analog Recording mode. You can only enable analog recording when you are already in normal recording mode. You need to Press Shift+Alt+F3 or goto Automation=>Analog Recording. As soon as you execute the command you get switched into Analog Recording Mode.

 1.7 Record and Run Settings

You can access the Record and Run Settings from Automation->Record and Run Settings. The usage of Record and Run Settings is explained below:
clip_image010[4]
Depending on the Add-Ins available you can see the Tab. For e.g. If you have Siebel Add-Ins or SAP Add-Ins, you can see the respective tab on this window. The tab allows you to provide the necessary settings for script recording and execution. We will explain the Web and Windows Tab.
Web Tab
Record and run Test on any open browser” - When you choose this option, QTP record the script on any open browser (Internet Explorer). As a best practice, you will select this option when you are doing the scripting for Web Based Application. Normally in real time, you record your test script by opening the AUT and framework is going to launch your AUT and perform the necessary actions as per Test Script.
Open the following address when a record or run session begins” – When you want to launch specific URL you can select this option. You can also set the default browser which will get launched when you start your recording or about to execute the Test Script. In real time we hardly use the second option. This is mostly used when people are learning the QTP Tool. The other 2 checkboxes – “Do not record and run on browsers that are already open” will ensure that actions are not getting recorded on other browser apart from the one which is launched while recording and “Close the browser when the test closeswill ensure that the AUT browser will get closed when you close the Test. Again these 2 options are hardly used in real time Test Automation.
Windows Tab
clip_image012[4]
In Windows Tab you can see following options to control your recording and execution on Windows Based Application.
Record and run Test on any Window-based application” - When you choose this option, QTP record the script on any open Window application which is supported by native OS (VB Application, MS Word, Notepad, Calculator etc). As a best practice, you will select this option when you are doing the scripting of Window Based Application. Normally in real time, you record your test script by opening the AUT and framework is going to launch your AUT and perform the necessary actions as per Test Script.
Record and run only on” – Under this checkbox you have other option to control your recoding and execution. You can specify the conditions such as “Record and Run Only On – Application opened by Quick Test”, “Record and Run Only On – Application opened by via the Desktop(by the Windows shell)”, “Record and Run Only On – Application Specified below – You will specify the application exe path in the grid section by navigating to the application exe path.” In real time we do not use the other options for Script Recording and Execution.

 1.8 Results

In case you are not able to view the results after test execution or later you want to see the result of last execution, you should navigate to Automation->Results. QTP will show the Result of the last Test execution. See the below Open Run Result Window which ask for Result path when you try to open the Result without opening any test or without executing the test.
clip_image014[4]
You can either open the Test using Test name and selecting the Run name or if you know the XML result file path, you can use Results XML File option to view the result.
If your test is opened and you want to view the result, click Automation->Results. It will display the last run results.

 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 Resources Menu and the usage of various features such as Object Repository, Object Repository Manager, Associate Repositories, Map Repository Parameters, and Associated Function Libraries.

Comments

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. ...