QTP is a UI automation framework designed mainly for Windows and Web-based applications. It works by identifying the objects in the application UI or a web page and performing the desired operations on them (like mouse clicks or keyboard events); it can also be used to capture object properties like name or handler ID etc. One of the most important topics in QTP is Object Identification.QTP uses a scripting language built on top of VBScript to specify the test procedure, and to manipulate the objects and controls of the application under test.
Though QTP is usually used for “UI Based” Test Case Automation, it can easily handle “Non-UI” based Test Cases. (e.g. API (Certification testing), Database Testing, etc.)
Some of the key features of QTP are:
Plug-ins are used to make recording more acceptable to a specific application, we use web plug-ins to automate test cases with respect to web applications. QTP has default plug-ins for ActiveX controls, web applications and VB objects. Plug-ins for other objects, such as Microsoft .NETobjects, are also available. Multimedia plug-ins and a plug-in for Windows Mobile are also available. In general, each QTP plug-in is available at an additional cost.
And QTP identifies the windows objects, even if we don’t select any plug-ins at the launching of the application .
Three types of licenses are available from HP:
1. Demo License : a 14-day demo license
2. Seat license : permanent seat license that is specific to the computer on which it is installed.
3. Floating (Concurrent): Floating allows a license to be shared between machines at any given point in time. (1 floating license allows QTP to be accessible from an entire lab’s worth of PCs but can only have 1 instance running at any given point in time).
Record and Playback
Initial development of automated tests with QTP is usually done by record-and-playback. A user’s actions are captured via Microsoft’s Component Object Model (COM). These are recorded into Actions, a kind of subroutine, as VBScript commands. All manipulated objects that QTP recognizes are also added to the object repository. Once recorded, the scripts are editable in either Keyword View or Expert View.
After clicking on the playback button all these actions will be played back. During playback, QTP attempts to identify and perform operations on the same objects, again using COM.
Checkpoints are a feature used for verifying the application under test. One can add a checkpoint to check if a particular object, text or a bitmap is present in the automation run.
In short, checkpoints are used to verify that during the course of test execution, the actual application behavior or state is consistent with the expected application behavior or state.
There are 10 types of checkpoints available in QTP:
1. Standard Checkpoint — Checks the properties of an object.
2. Table Checkpoint — A Standard Checkpoint that checks the properties of a table.
3. Image Checkpoint — A Standard Checkpoint that checks the properties of an image.
4. Bitmap Checkpoint — Compares an area of the application under test pixel-for-pixel with the screen as seen at record-time.
5. Database Checkpoint — Used to automate back-end testing.
6. Text Checkpoint — Checks that a section of text is found between two other sections of text.
7. Text Area Checkpoint
8. Page Checkpoint — Checks the properties of a web page.
9. Accessibility Checkpoint — Checks the accessibility of an application.
10. XML Checkpoint
The VBScript Reporter.ReportEvent function also produces output very similar to that of a checkpoint, allowing the creation of custom checkpoints.
Recovery is the name for exception handling in QTP, with the goal of enabling the tests to continue to run if an unexpected failure occurs. For instance if an application crash occurs and a message dialog appears, QTP can be instructed to attempt to restart the application and continue with the rest of the test cases from there
This feature is used to store the run-time values/data that are displayed in the application into the run-time data table, so that we can use these run-time values in the script for further use.
Say we need the value which is dynamically created or processed by application for later use, we can go for output concept. We can follow the following example to understand. If the application produces an id for the person and we need that id, that can be solved using output concept, where we store value ‘id’ of that person in the data table and we can refer to that value later.
The data table is a table primarily used to implement data-driven testing. It is implemented as a Microsoft Excel workbook that can be accessed from within QTP. There are two types of Data Tables available in QTP: the Global data sheet and the local data sheets. The Global data sheet is a single sheet which is accessible from every Action in a test. By default, each row of this sheet specifies the values to be used in an iteration of the entire test. The data table can be managed by other third party tools such as Grid Tools Datamaker, which offers features such as Data inheritance; substitution variables and version control.
There is also one local data sheet associated with each Action. As the Global data sheet specifies iterations of an entire test, these sheets are often used to set up iterations of a single Action. The data in these sheets can only be accessed from their associated Action. While it is possible to access a different Action’s local data sheet, it cannot be done from the Object Repository or from inside a checkpoint.
Complex objects may not be recognized properly by QTP. The Virtual Object concept was implemented to enable users to add some degree of support for these objects. If an object is not recorded out-of-the-box, an experienced user may be able to define that object as a personal virtual object and build a virtual object repository. Assuming that the required information can be extracted from the object, this allows the users to successfully record and playback against that object. In practice, this is not always possible.
This feature can be used to calculate the time required to run a particular test or particular steps in the tests. Transactions are most often used in automated software performance testing, so they are infrequently used in QTP(Quick test Professional)
QTP generates the result file for the test cases at the end of test in the form of XML tree. The result file provides detail regarding PASS and FAILS counts, error messages, and potentially supporting information that allows users to determine the underlying cause of a failure.
QuickTest provides two main views of a script: Keyword View and Expert View. They are selected from tabs at the bottom of the QuickTest Professional window.
Keyword View is QTP’s default test procedure interface. It displays the automation steps of a test procedure as a descriptive tree of Actions and functions. The tree contains columns listing the Action or function name, any parameters, and comments. This mode is most useful for the beginners in operating with the tool. This view allows the user to select the objects either from the application or from the Object Repository and the user can select the methods to be performed on those objects. The script is automatically generated. Users can also set check points from keyword view.
In Expert View, QTP allows display and editing of the a test’s source code. All test actions can be edited here except for the root Global action. Expert View acts as an IDE for the test. It includes most standard IDE features, such as breakpoints. This view is most suitable for the advanced users, enabling them to customize the test, such as by writing user-defined functions.
Supports VB Script. Supports classes but not supports polymorphism and inheritance.