Friday, April 29, 2011

13 great tips from HP to fine tune your QTP Actions.

1) You can configure an action for repeated use in your test and in other tests. Select the Reusable Action check box in the Action Properties dialog box (Edit > Action > Action Properties).
2) You can use the ExitAction statement to terminate an action before it finishes running, based on conditions you specify in your test.
3) You can specify test, action, or component parameters to pass values to and from your test or business component, and between actions in your test.
4) You can define test or action parameter variables using the Parameter object and its methods in the Expert View.
5) You can create test, action, or component parameter output values that retrieve values during the run session and store them for use at another point in the run session. You can then use these output values to parameterize a step in your test or business component.
6) NEW!! You can now associate multiple object repositories with an action or application area. In previous versions of QuickTest Professional, you could associate only a single object repository with a test asset.
7) NEW!! You can associate shared object repositories with multiple actions simultaneously, using the Associate Repositories dialog box.
8) NEW!! You can resolve missing resources (such as missing object repositories and actions), using the new Missing Resources pane.
9) You can print a single action or business component from the Keyword View (in table format) or the from the Expert View (in statement format).
10) In addition to Data Table output values, you can output values to environment variables or store a retrieved value in a test, action, or component parameter.
11) You can specify a relative path when calling actions, functions, and other external files associated with or referenced by a test or business component.
12) You can use the Data Driver Wizard to automatically parameterize constants in your action or business component.
13) If you want to add the same comment to every action that you create, you can add the comment to an action template.

What are QTP transactions?

This is a rarely discussed topic in QTP. I would like to give an overview of what it is and how to use it in QTP.

A transaction represents the process in your application that you are interested in measuring. By defining a transaction you can measure how long it takes to run a section of a test script.

Need for Transactions:
Transactions can be used to measure the performance of the script
By analyzing the output of the Transaction we can optimize the script in certain areas

Defining a Transaction:

You define transactions within your test by enclosing the appropriate sections of the test with start and end transaction statements. During the test run, the StartTransaction step signals the beginning of the time measurement.

The time measurement continues until the EndTransaction step is reached.

The test report displays the time it took to perform the transaction.

Tuesday, April 26, 2011

QTP TIP :How to convert system date to other date format?

We can use the following code to convert system date to other formats:-


1: MyDate = Date
2: msgbox MyDate
3: MyDay = day(MyDate)
4: MyMonth = Month(MyDate)
5: MyYear = Year(MyDate)
6: msgbox "Date in DD/MM/YYY format is - " & MyDay & "/" & MyMonth & "/" & MyYear
7: msgbox "Date in MM/DD/YYYY format is - " & MyMonth & "/" & MyDay & "/" & MyYear

Explanation:-
1. System date in extracted into variable MyDate
3. day function extracts the day from given date.
4. month function extracts the month from given date.
5. year function extracts the year from given date

Launching QTP through a VB script

Following VB script can be used to launch QTP.

1: Dim QTPObj
2: Dim QTPTest
3: Set QTPObj=CreateObject("QuickTest.Application")
4: If Not QTPObj.Launched then
5: QTPObj.Launch
6: End if
7: QTPObj.Visible=True
8: QTPObj.Open "Path of QTP script"
9: Set QTPTest=QTPObj.Test
10: QTPTest.Run
11: QTPTest.Close
12: QTPObj.Quit
Line by line Explanation:-
Line 1: Declare object for QTP
Line 2: Declare object for QTP test
Line 3: Create QTP object
Line 4: If condition to verify if QTP is running or not
Line 5: If QTP is not running, launch QTP session
Line 6: End of if statement
Line 7: Make QTp Visible. If thi sproperty is set to False, QTP qould be launched (at backend), but would not be visible to user.
Line 8: Open the QTP test to run by specifying the path
Line 9: Map the QTP test with object
Line 10: Run the QTP test
Line 11: Afterthe test is completed. close QTP
Line: Quitting the obect created.

Friday, April 22, 2011

QTP Test Object Model

Test object Model is a set of object types or Classes that QuickTest uses to represents the objects in our application.
A test object class comprises of a list of properties that can individually (uniquely) identify objects of that class and a set of appropriate methods that QuickTest can record for it.
A test object is an object that QuickTest creates in the test to correspond to (represent) the actual object in the application. QuickTest uses the stored information about the object during the run session to identify and check the object. A run-time object is the real (actual) object in the application or Web site on which methods are performed during the run session.
Properties and methods of objects:
The property set for each test object is created and maintained by QuickTest. The property set for each run-time object is created and maintained by the object architect (creator) (Microsoft for Internet Explorer objects, Netscape for Netscape objects).
Similarly, methods of test objects are methods that QuickTest recognizes and records when they are executed (performed) on an object while we are recording, and that QuickTest executes when the test or component runs. Methods of Run-time object are the methods of the object in theapplication as defined by the object architect (creator). We can access and execute run-time object methods using the Object property.
Some important points to remember about methods and properties :

Each test object method we execute (perform) while recording is recorded as a separate step in the test. When we run the test, QuickTest executes (performs) the recorded test object method on the run-time object.

Properties of test object are captured from object while recording. QuickTest uses the values of these properties to identify runtime objects in the application during a run session.

Property values of objects in the application may change .To make the test object property values match the property values of the run-time object, we can modify test object properties manually while designing the test or component or using SetTOProperty statements during a run session. We can also use regular expressions to identify property values.

We can view or modify the test object property values that are stored with the test or component in the Object Properties or Object Repository dialog box.

We can view the syntax of the test object methods as well as the run-time methods of any object on our desktop using the Methods tab of the Object Spy.

We can retrieve or modify property values of the TEST OBJECT during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View. We can retrieveproperty values of the RUNTIME OBJECT during the run session by adding GetROProperty statements. If the available test object methods or properties for an object are not sufficient or they do not provide the functionality we need, we can access the internal methods and properties of any run-time object using the Object property. We can also use the attribute object property to identify Web objects in the application according to user-defined properties.

QTP Testing Process

QTP (QuickTest Professional) lets you create tests and business components by recording operations as you perform them in your application.
Test - A compilation of steps organized into one or more actions, which we can use to verify that our application performs as expected. A test is composed of actions (3 kinds of actions are there in QTP Non-reusable action, Reusable action and External action).
1) First step is Planning Before starting to build a test, you should plan it and prepare the required infrastructure.
For example, determine the functionality you want to test, short tests that check specific functions of the application or complete site.
Decide how you want to organize your object repositories.
2) Second step in QTP is Creating Tests or Components
We can create a test or component by
a) Either recording a session on your application or Web site.
As we navigate through the application or site, QuickTest graphically displays each step we perform as a row in the Keyword View. The Documentation column of the Keyword View also displays a description of each step in easy-to-understand sentences. A step is something that causes or makes a change in your site or application, such as clicking a link or image, or submitting a data form.
OR
b) Build an object repository and use these objects to add steps manually in the Keyword View or Expert View. We can then modify your test or component with special testing options and/or with programming statements.
3) Third step is Inserting checkpoints into your test or component.
A checkpoint is a verification point that compares a recent value for a specified property with the expected value for that property. This enables you to identify whether the Web site or application is functioning correctly.
4) Fourth step is
Broaden the scope of your test or component by replacing fixed values with parameters.
To check how your application performs the same operations with different data you can parameterize your test or component.
When you parameterize your test or component, QuickTest substitutes the fixed values in your test or component with parameters
Each run session that uses a different set of parameterized data is called an iteration.
We can also use output values to extract data from our test or component. An output value is a value retrieved during the run session and entered into the Data Table or saved as a variable or a parameter. We can subsequently use this output value as input data in your test or component.
We can use many functional testing features of QuickTest to improve your test or component and/or add programming statements to achieve more complex testing goals.
5) Fifth step is running the test
After creating test or component, we run it.
Run test or component to check the site or application.
When we run the test or component, QuickTest connects to your Web site or application and performs each operation in a test or component, checking any text strings, objects, or tables you specified. If we parameterized the test with Data Table parameters, QuickTest repeats the test (or specific actions in your test) for each set of data values we defined.
Run the test or component to debug it.
We can control the run session to identify and eliminate defects in the test or component. We can use the
Step Into,
Step Over,
And Step Out
commands to run a test or component step by step.
We can also set breakpoints to pause the test or component at pre-determined points.
We can view the value of variables in the test or component each time it stops at a breakpoint in the Debug Viewer.
6) Sixth step is analyzing the results
After we run test or component, we can view the results.
➤ View the results in the Results window.
After running the test or component, we can view the results of the run in the Test Results window. We can view a summary of the results as well as a detailed report.
➤ Report defects identified during a run session.
If Quality Center is installed, we can report the defects fond out to a database. We can instruct QuickTest to automatically report each failed step in the test or component, or we can report them manually from theTest Results window.

What is QTP ??

QTP (QuickTest Professional) is HP's advanced keyword-driven testing solution. QTP (QuickTest Professional) provides for functional test and regression test automation.
With QTP (QuickTest Professional) you will be able to test

Standard Windows applications
Web objects,
ActiveX controls, and
.Net
Java
SAP (Systeme, Anwendungen und Produkte in der Datenverarbeitung, Systems, Applications and Products in Data Processing)
Visual Basic applications.
Siebel
Oracle
PeopleSoft and
Terminal emulators ( http://www.emtec.com/zoc/terminal-emulator.html)

We need additional QuickTest add-ins for special environments e.g. .Net, Terminal emulators. The current version of QTP (version 10.0) supports running tests on the following browsers:
. Microsoft Internet Explorer 6.0 Service Pack 1 or 7.0 Beta 2 and lower,
. Netscape Browser 8.0
. Mozilla FireFox 1.5.
QuickTest Professional 9.2 is compatible with: SAP 8.2, .NET 9.2, Web Services 9.2, Java 9.1, Oracle 8.2, PeopleSoft 8.2, Siebel 8.0, Stingray 8.2, Terminal Emulator 8.0, and VisualAge Smalltalk 8.2.
QTP (QuickTest Professional) is Unicode compliant according to the requirements of the Unicode standard, enabling you to test applications in many international languages.
As and when an application under test changes, such as when a "Log in" button is renamed "Sign Into," we can make one update to an XML-based Shared Object Repository (within the new Object Repository Manager), and the update will circulate (propagate) to all tests that reference this object. QuickTestProfessional keeps object-level changes synchronized among users throughout test creation efforts.

Thursday, April 21, 2011

QTP Script: Checking if Data table sheet exists

Is there any way to check if a DataTable sheet exists? Yes, offcourse. Open the DataTable and see manually. Now, is there any way to check through code if a DataTable sheet exists? Hmmmm.. Yes it is.

I have created a small algorithm to check if a HP QTP DataTable sheet exists or not. The algorithm goes here:

Step I : Use the On Error Resume Next statement to disable any error popups.
Step II : Use the DataTable's GetSheet method to return the specified sheet. The following syntax should be used:
DataTable.GetSheet("Your Sheet")
Step III : Check for an error number using Err.Number. If case of no error, Err.Number should return 0.

With the above algorithm, our QTP Script goes here:

'Disable Error Reporting in QTP
On Error Resume Next

'Check for the existence of a sheet inside QTP
DataTable.GetSheet("Global")

If Err.Number<>0 Then
Msgbox "The specified Sheet does not exists"
Else
Msgbox "The specified Sheet exists"
End If

'Enable Error Reporting in QTP
On Error Goto 0

How to View Object Properties by using Object Spy

This short tutorial guides you to a method by which you can view the Object Properties & Methods with the help of Object Spy in QTP.

We can view the Properties and Methods of any object in an open application with the help of Object Spy pointing hand mechanism. As we move the pointing hand over the objects in the application, ठिर details get displayed in the Object Spy.

These details displayed in the Object Spy are the hierarchy tree of the test object, its properties and values, and the methods associated with the object. For methods, the syntax is also displayed.

Steps to view test object properties or methods:

Step-1: Open the application to the page containing the object on which we want to spy say google.com.

Step-2: Choose Tools > Object Spy or click the Object Spy toolbar button to open the Object Spy dialog box and display the Properties tab.

Or click the Object Spy button from the Object Repository dialog box.

Step-3: Select the details we want to view for the object.

  • Click Run-time Object Properties or Test Object Properties radio button.
  • To view the object’s available methods and syntax, click the Methods tab. Properties tab is displayed by default, enabling us to view the object’s properties and values.
Step-4: In the Object Spy dialog box, click the pointing hand which is displayed on top. QuickTest remains hidden. As we move the pointing hand over the test objects in our application, the test objects get highlighted, and we can view their test object properties or methods in the Object Spy dialog box. We can also view their parent objects in the object hierarchy tree area of the Object Spy dialog box.

Step-5: Highlight or click the object whose properties or methods we want to view। The Object Spy displays the object hierarchy tree and the properties or methods of the object that is selected within the tree.


Step-6: Click the object whose associated methods we want to view. The Object Spy displays the object hierarchy tree and details for the selected object according to our selection.

Step-7: To view the properties or methods of the test object, click the Test Object Properties radio button. To view the properties or methods of the run-time object, click the Run-time Object Properties radio button.

Step-8: If we want to view properties, values, or methods for another object within the displayed tree, highlight or click the object in the tree and select the relevant options, as described in step 3 above.

Step-9: If we want to copy an object property or value, or a method’s syntax to the Clipboard, click the property, value, or method to highlight it. The value gets displayed in the selected property / value or method syntax box which is located above the Description box. Highlight the text in the box and use CTRL + C to copy the text to the Clipboard or right-click the highlighted text and choose Copy from the menu.

Keywords: QTP, Quicktest Professional, QTP Object Spy, QTP Tutorials
In my previous article of Checking if a Data Table Sheet exists, I have shown a QTP script which checks if a sheet exists or not in your Datatable. Today, I am going to show you how to check if a parameter exists or not in your DataTable.

The algorithm goes here:

Step I : Use the On Error Resume Next statement to disable any error popups.
Step II : Use the DataTable's GetSheet method to return the specified sheet. Then add the GetParameter method to seach for the parameter. The following syntax should be used:
DataTable.GetSheet("Your Sheet").GetParameter(" Your Parameter")
Step III : Check for an error number using Err.Number. If case of no error, Err.Number should return 0.

With the above algorithm, our QTP Script goes here:

'Disable Error Reporting in QTP
On Error Resume Next

'Check for the existence of "Global" sheet inside QTP. Then search for "HPQTP" parameter inside "Global" sheet
DataTable.GetSheet("Global").GetParameter("HPQTP")

If Err.Number<>0 Then
Msgbox "The specified parameter does not exists"
Else
Msgbox "The specified parameter exists"
End If

'Enable Error Reporting in QTP
On Error Goto 0

Click here to see the script for Checking if Data table sheet exists

QTP Tutorial: Moving mouse to a particular object

Sometimes its required to place your mouse cursor on an object in your application and then perform some operation like clicking that object or even right clicking. I have created a short QTP tutorial for moving your mouse cursor on any object in your application.

I used Google webpage to create this small tutorial on HP Quicktest Professional. This script will hover over the mouse cursor inside the search box.(It will not click inside the search box, it will simply bring the mouse over the search box)

The QTP Script goes here:

x=Browser("micclass:=Browser").Page("micclass:=Page").WebEdit("name:=q").
GetROProperty("abs_x")
y=Browser("micclass:=Browser").Page("micclass:=Page").WebEdit("name:=q").
GetROProperty("abs_y")

Set obj=CreateObject("Mercury.DeviceReplay")

obj.MouseMove x,y

Please make sure to resize your QTP window and your application before running the above HP QTP script as shown below to see the effect:

As you have noticed, your mouse cursor has been shifted to the extreme left corner of the search box. To place it somewhere in the middle, modify the fourth line in the above script to:

obj.MouseMove x+10,y+10

The output after modifying the QTP script would be as shown below:

Explanation of the above QTP code:

1. "abs_x" and "abs_y" are the object's absolute x and y coordinate relative to the screen. Hence we are finding the extreme top-left coordinate of the search box using the first two lines.

2. Mercury.DeviceReplay object is an undocumented feature in QTP which is usually used to simulate either keyboard inputs or mouse clicks or mouse movements. Also, to use "Mercury.DeviceReplay" object in HP Quicktest Professional, you need to make sure that your Application is currently the active window. So for the above code, we created an object reference for DeviceReplay object in QTP( here in our case, I used obj) and using that object reference, we used the MouseMove method to shift the mouse cursor to the desired location.

Just like we used MouseMove to shift my mouse cursor over the search box, we can also simulate clicking on an object using MouseClick.

Syntax of MouseClick Method

object.MouseClick x,y, Button

object: It should always be Mercury.DeviceReplay object
x: The object's absolute x coordinate relative to the screen
y: The object's absolute y coordinate relative to the screen
Button: It can have 3 values
1. For Left Mouse Click use 0
2. For Middle Mouse Click use 1
3. For Right Mouse Click use 2

Hence, if we want to do a left mouse click inside Google search box, our QTP script would be:

x=Browser("micclass:=Browser").Page("micclass:=Page").WebEdit("name:=q").
GetROProperty("abs_x")

y=Browser("micclass:=Browser").Page("micclass:=Page").WebEdit("name:=q").
GetROProperty("abs_y")


Set obj=CreateObject("Mercury.DeviceReplay")

obj.MouseClick x+10,y+10,0

And, if you want to do a right mouse click, replace the last line of above code with the following:

obj.MouseClick x+10,y+10,2

Note: The above code will run successfully if you will resize your QTP window while the script is running so that the search box is not hidden by the QTP window while the script is running otherwise it may not work as desired.

Do you have any questions related to this QTP Article? Feel free to ask me. Please post your queries in the comments section.

Click here to read how to check if a DataTable Parameter exists or not

Click here to read how to check if a DataTable Sheet exists or not

Click here to read tutorial on Regular Expressions

QTP Tutorial Database Checkpoint



Lets try out our hands on Database checkpoint: using Oracle 9i
First of all you have to connect oracle 9i to QTP 9.(before doing any recording)
  1. For this go to Insert -> Checkpoint -> Database Checkpoint.
  2. A Database Query Wizard opens.
    Select ' Specify SQL statement manually' from the Query definition area. Click Next.
  3. Here click on 'Create' button which is on the right of "Connection String:" It will open 'Select Data Source' window. Click on 'Machine Data Source' Tab
  4. Click on New Button.
  5. 'Create New Data Source' window opens.
  6. Select 'User Data Source' from Select a type of data source. Click Next.
  7. It will show all the data source drives it could find.
  8. Select Oracle (on my machine it was 'Oracle in OraHome9'). Click Next. Click Finish.
  9. It will open 'Oracle ODBC Driver Configuration' window.
  10. Enter 'Data Source name' ( I entered "oracle")
  11. Enter 'description' (I entered "SQL")
  12. Select 'TNS Service Name' ( I selected 'DB02', my oracle database name) from combo box.
  13. Enter userid (I used SCOTT).
  14. Click 'Test Connection' Button. It will ask for a Password. Enter your password for Oracle.
  15. If successful it will show 'Testing Connection' window with 'Connection Successful' written on it.
This completes our task of Connecting QTP with Oracle.
Now we will record a test.
  1. Open a blank test.
  2. Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Windows Applications" tab and choose first option "Record and run test on any open Windows based application." and click on ok.
  3. Go to Insert (menu)->Checkpoint->Database Checkpoint
  4. A 'Database Query Wizard' opens.
  5. Select ' Specify SQL statement manually' from the Query definition area. Click Next. Click Create.
  6. Go to 'Machine Data Source' Tab
  7. Select Oracle from data source name. Click Ok. It will open 'Oracle ODBC Driver Connect'.
  8. Enter password. Click ok
  9. It will come to Database Query Wizard window with 'Connection String' field filled with: "DSN=oracle;UID=SCOTT;PWD=TIGER;DBQ=DB02;DBA
    =W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;
    LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F;
    MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;"
  10. In the SQL Statement area type "select * from emp;". Click Finish.
  11. It will open 'Database Checkpoint Properties' window with the result of the query. Click Ok.
  12. Click Stop in order to stop the Recording.
  13. In the Expert View, it just adds one line "DbTable("DbTable").Check CheckPoint "DbTable")"
This is the simplest database checkpoint example.
Now run it.
Click on Run. ( we don't need to open any other window or application to run this as our Oracle is running at the back end as a service - default way in which it was installed- nothing special.)
When it is passed it will show following in the Result window:
Test Checkpoint-database Summary (where Checkpoint-database is the name with which I saved the test)
Run-Time Data Table
Checkpoint-database Iteration 1 (Row 1)
Action1 Summary
DbTable
Checkpoint "DbTable"
( when you click on this, in details it will show checked 112 cells (in your case number of cells may differ). It means if you go to the oracle and add or delete any row and run this test again it will fail.)

QTP 10 keyword view

In QTP (QuickTest Professional) we first of all record a test, then run a test and then analyze the results, but before running the test we can also enhance it with checkpoints and parameters.
First of all let's talk a little about keyword view in QTP and then we will talk about recording in QTP and then we will move on to other things.
After recording all the operations, QuickTest displays them as steps in the Keyword View, and generates them in a script (in an Expert View).
In the keyword view there are 4 visible columns –
(For other valuable information on below points please see QTP user guide pg 92 and pg 114)
Item The item on which we want to perform the step and it can be a test object, utility object, function call, or statement. This column shows a hierarchical icon-based tree. The highest level of the tree is actions, and all steps are contained within the relevant branch of the tree. Operation The operation (methods or functions) to be performed on the item selected in the Item column, for example, Click or Select.
Value The argument values for the selected operation, for example, the mouse button to use when clicking the image.
Documentation It is a Read-only auto-documentation of what the step does in an easy-to-understand sentence, for example, Click the "findFlights" image.
Assignment The assignment of a value to or from a variable for example, Store in cCols would store the return value of the current step in a variable called cCols so you can use the value later in the test. This column is not visible by default. Comment Any textual information you want to add regarding the step. This column is also not visible by default.

Actions in HP QTP software

Actions break up the test into logical sections/units such as specific activities that we perform in our application.
When we create a new test, it contains a call to one action. By breaking up the tests into calls to multiple actions, we can design more modular and well organized and professional tests. An action has its own test script, containing all of the steps recorded in that action, and all objects in its local object repository. An action is stored with the test in which you created it.
If you create a test in which you log into the system (email), check inbox, and then log out of the system (email), your test might be structured as shown—one test calling three separate actions:

Test 1
Actions stored with Test 1
Call to action 1 ---> Action 1(Logging In)
Call to action 2 ---> Action 2(Checking Inbox Mails)
Call to action 3 ---> Action 3(Logging Out)
Actions make it possible to parameterize and iterate over specific elements of a test. They also make it easier to re-record steps in one action when part of your application changes. For every action called in the test, QuickTest creates a corresponding action sheet in the Data Table so that we can enter Data Table parameters that are specific to that action only.
Three types of actions are:
Non-reusable action This non reusable action can be called only once and that too in the test with which it is stored.
Reusable action Reusable actions are like functions in any programming language. If there is a process that needs to be included in several tests, we can record, modify, and enhance the steps of the process and save them in a reusable action. Then we can call the action from other tests, rather than recording, modifying, and enhancing the same steps each time. It can be called several times by the test with which it is stored (the local test), as well as by other tests.
Deleting a reusable action that is called by other tests will cause those tests to fail.
External action is a reusable action stored with another test. External actions are read-only in the calling test, but we can choose to use a local, editable copy of the Data Table information for the external action. When a call to an external action is inserted, the action is inserted in read-only format
We can create an additional call to any reusable or external action in the test by pressing CTRL while we drag and drop the action to another location at a parallel (sibling) level
within the test.
By default, new actions are non-reusable. Each action created in a test can be marked as reusable or non-reusable.
When we run a test with multiple actions, the test results are divided by actions within each test iteration so that we can see the outcome of each action, and can view the detailed results for each action individually.
If you expect other users to open your tests and all actions in your tests are stored in the same drive, you should use relative paths for your reusable actions so that other users will be able to open your tests even if they have mapped their network drives differently.

Parameterizing Tests in QTP (QuickTest Professional )


By replacing fixed values with parameters QuickTest enables you to enlarge the scope of a basic test. It is known as parameterization, greatly increases the power and flexibility of a test. A parameter is a variable that is assigned a value from an external data source or generator. Values in steps and checkpoints and also the values of action parameters can be parameterize.
Parameters let us check how the application performs the same operations with multiple sets of data.
There are four types of parameters in QTP:
Test/action parameters: Test parameters make possible for us to use values passed from the test. Action parameters enable us to pass values from other actions in your test. To use a value within a specific action, the value must be passed down through the action hierarchy of the test to the required action. We can then use that parameter value to parameterize a step in the test. For example, suppose that we want to parameterize a step in Action3 using a value that is passed into the test from the external application that runs (calls) the test. We can pass the value from the test level to Action1 (atop-level action) to Action3 (a nested action of Action1), and then parameterize the required step using this action input parameter value (that was passed through from the external application). Alternatively, we can pass an output action parameter value from an action step to a later sibling action at the same hierarchical level. For example, suppose that Action2, Action3, and Action4 are sibling actions at the same hierarchical level, and that these are all nested actions of Action1. We can parameterize a call to Action4 based on an output value retrieved from Action2 or Action3. We can then use these parameters in the action step.
Data Table parameters allow us to create a data-driven test (or action) that runs several times using the data that we supply. In each repetition, or iteration, QuickTest uses a different value from the Data Table.
Environment variable parameters allow us to use variable values from other sources during the run session. These may be values that we supply, or values that QuickTest generates for us based on conditions and options we choose.
Random number parameters Enable us to insert random numbers as values in your test.
Values in steps and checkpoints can be parameterized while recording or editing the test.
The values of object properties can be parameterized for a selected step.
The values of the operation (method or function arguments) defined for the step can also be parameterized.
When the value of an object property for a local object is parameterized, we are amending the test object description in the local object repository. Therefore, all occurrences of the specified object within the action are parameterized.
Parameterizing the value of a checkpoint property enables us to check how an application or Web site performs the same operation based on different data.

Software Automation Testing Benefits

1. Saves time during the test execution: The execution of an automation test case( test script) is faster compared to the manual execution of a test case.

2. Execution of tests in un-attended mode: Once the entire automation suite( the automated test cases of the manual test case suite) is reayd for the execution, the automation suite can be executed in an un-attended mode( human attendance is not required for the entire execution), if the framework is designed in such a way. You can use the human brain for better innovative testing to improve the productivity of the overall testing process.

3. Consistency of test execution: When you execute manual regression suite several times, it is a general human tendency that we get bored of executing the same test cases time and again and because of which we may miss to execute one or many steps which may finally lead to an undetected bug!!! But, if you execute the automation suite, may be for 1 time or 100 times, it executes with the same efficiency and effectiveness.

4. Reducing cycle time of regression test cycles.

5. Data Driven Testing: This feature helps to parameterize the data in the script. This helps to get rid of hard coding of the values required for the test. Also, this feature helps in the concept of Retesting i.e, re-execution of the test/functionality with multiple sets of input data.

6. Coverage: Test coverage can be increased with the help of Automation. In real-time, testers have very less time to test n number of features. This makes the testers limit their scope in testing the application/products by determining the priority of the feature/functionality to be tested. But, that limitation can be overcome to a great extent with the help of automation.

With the above benefits of automation, automation has actually become a part of the entire life project life cycle and more importantly Automation life cycle has become an important subset of the entire Test life cycle. To reap good benefits from Test Automation to the entire project, you need to have good planning and coordination from the Development team, Manual Testing team and the Automation team.

HP QTP recording modes

The default mode of recording is the Normal recording mode. There are other

recording modes also like Analog Recording or Low Level Recording. Normal mode is the default and takes full advantage of the QuickTest test object model, as it recognizes the objects in the application regardless of their location on the screen.
Analog Recording : Exact mouse and keyboard operations are recorded in relation to either the screen or the application window. In this QTP also records and tracks every movement of the mouse for example, recording a signature produced by dragging the mouse. Analog Recording steps are not editable from within QuickTest.
Low Level Recording : At any time, if an environment or on an object not recognized by QuickTest, use Low Level Recording. It records at object level and records all run-time objects as Window or WinObject test objects. QuickTest records all parent level objects as Window test objects and all other objects as WinObject test objects.
Each step recorded in Low Level Recording mode is shown in the Keyword View and Expert View.
All the three modes of recording can be used in a single test e.g. we can switch to either Analog Recording or Low Level Recording in the middle of a recording session for specific steps and then return to normal recording
mode
.
Analog Recording and Low Level Recording require more disk space than normal recording mode.
Use Analog Recording when :
The actual movement of the mouse is what you want to record.
Recording in Analog mode can be relative to the screen or relative to a specific window (see user guide for detail)
In Analog Recording a separate file is saved and stored with the action.
In Analog Recording mode, QuickTest adds to your test a RunAnalog statement that calls the recorded analog file.
Use Low Level Recording when :
Environments or objects not supported by QuickTest.
Exact location of the operation on your application screen is necessary. in normal mode QuickTest performs the step on an object even if it has moved to a new location on the screen.
If the location of the object is important to your test, switch to Low Level Recording

QTP Web Services

What are web services?

Web Services: A vague term that refers to distributed or virtual applications or processes that use the internet to link activities or software components.

With the use of Web services, an application can publish its function or message to the rest of the world.

For example a travel website that takes a reservation from a customer, and then sends a message to a hotel application, accesses via the web, to determine if a room is available, books it, and then tells the customer he or she has a reservation is an example of a web services application. [Real world web services By Will Iverson]

Why web services are important when we have other technologies like RMI, CORBA etc.?

Web Services are platform-independent and language-independent, since they use standard XML languages. This means that my client program can be programmed in C++ and running under Windows, while the Web Service is programmed in Java and running under Linux.

Most Web Services use HTTP for transmitting messages (such as the service request and response). This is a major advantage if you want to build an Internet-scale application, since most of the Internet's proxies and firewalls won't mess with HTTP traffic.

One of the oft-cited advantages of web services is the fact that they lend themselves naturally to build loosely coupled systems. These types of systems are more scalable than strongly coupled systems, and impose fewer architectural requirements on the actual implementation of the web services. Suffice it to say that the reason why web services are ideal to build loosely coupled systems is because they are message-oriented and rely on language-neutral XML dialects to send messages, to specify interfaces, etc.

What are the disadvantages of web services?

Overhead: Transmitting all your data in XML is obviously not as efficient as using a proprietary binary code. What you win in portability, you lose in efficiency. Even so, this overhead is usually acceptable for most applications, but you will probably never find a critical real-time application that uses Web Services.

Lack of maturity: Web Services are relatively new and, though the core specifications that deal with fundamental languages (XML, WSDL,..) and protocols (HTTP, SOAP,…) are pretty stable the world of web services is still evolving at a fast pace. Standards dealing with more advanced capabilities expected from distributed systems, such as transactions, security, etc. are either very new or still in the works. [Globus Toolkit 4: programming Java Services By Borja Sotomayor, Lisa Childers]

Some Definitions:

Web Services Description Language (WSDL)

WSDL (Web Services Description Language) is an XML-based language for describing Web services and how to access them. You can see more on it here.

SOAP (Simple Object Access Protocol, or Service Oriented Architecture Protocol)
SOAP is a simple XML-based protocol to let applications exchange information over HTTP. You can see more on it here.

UDDI (Universal Description, Discovery and Integration)

Universal Description, Discovery and Integration (UDDI) is a directory service where businesses can register and search for Web services.

UDDI is a platform-independent framework for describing services, discovering businesses, and integrating business services by using the Internet.

UDDI stands for Universal Description, Discovery and Integration
UDDI is a directory for storing information about web services
UDDI is a directory of web service interfaces described by WSDL
UDDI communicates via SOAP
UDDI is built into the Microsoft .NET platform
You can see more on it here.

A small example of Web Service (invocation) to make it even more understandable:

1. A client may have no knowledge of what Web Service it is going to invoke. So, our first step will be to discover a Web Service that meets our requirements. For example, we might be interested in locating a public Web Service which can give me the weather forecast in US cities. We'll do this by contacting a discovery service (which is itself a Web service).

2. The discovery service will reply, telling us what servers can provide us the service we require.

3. We now know the location of a Web Service, but we have no idea of how to actually invoke it. Sure, we know it can give me the forecast for a US city, but how do we perform the actual service invocation? The method I have to invoke might be called "string getCityForecast(int CityPostalCode)", but it could also be called "string getUSCityWeather(string cityName, bool isFarenheit)". We have to ask the Web Service to describe itself (i.e. tell us how exactly we should invoke it).

4. The Web Service replies in a language called WSDL.

5. We finally know where the Web Service is located and how to invoke it. The invocation itself is done in a language called SOAP. Therefore, we will first send a SOAP request asking for the weather forecast of a certain city.

6. The Web Service will kindly reply with a SOAP response which includes the forecast we asked for, or maybe an error message if our SOAP request was incorrect.
For more on web services you can read [Globus Toolkit 4: programming Java Services By Borja Sotomayor, Lisa Childers]

QTP checkpoints tutorial

A checkpoint enables you to identify whether the Web site or application under test is functioning correctly or not by comparing a current value for a particular property with the expected value for that property.
After we add a checkpoint, QuickTest adds a checkpoint to the current row in the Keyword View and adds a Check CheckPoint statement in the Expert View.
By default, the checkpoint name receives the name of the test object on which the checkpoint is being performed. We can change the name of the checkpoint if
needed.
Types of Checkpoints:
  1. Standard checkpoint
  2. Image checkpoints
  3. Bitmap Checkpoint
  4. Table checkpoints
  5. Accessibility Checkpoint
  6. Text Checkpoint
  7. Page Checkpoint
  8. Database Checkpoint
  9. XML checkpoints
Standard checkpoints allow checking the object property values in the Web site or application under test. Standard checkpoints evaluate (compare) the expected values of object properties captured during recording to the object's current values during a run session. For example we can check that a radio button is activated after it is selected. Standard checkpoints are supported for all add-in environments.
Standard checkpoints can be used to perform checks on
Images,
Tables,
Web page properties, and
Other objects within your application or Web site.
Standard checkpoints can be created for all supported testing environments (as long as the appropriate add-in(s) are loaded).
Image checkpoints allow you to check the properties of an image in the application or Web page. For example, you can check that a selected image's source file is correct or not. An image checkpoint can also be created by inserting a standard checkpoint on an image object. Image checkpoints are supported for the Web add-in environment
With Bitmap Checkpoint we can check an area of a Web page or application as a bitmap. While creating a test, we have to specify the area to check by selecting an object. An entire object or any area within an object can be checked. Bitmap checkpoints are supported for all add-in environments
By adding table checkpoints to the test, we can check the content of tables displayed in the application. For example, we can check that a specified value is displayed in a certain cell. Certain environments also support checking the properties of the table object. For example, a check that a table has the expected number of rows and columns. A table checkpoint can also be created by inserting a standard checkpoint on a table object.
Accessibility Checkpoint recognizes areas of your Web site that may not conform to the World Wide Web Consortium (W3C) Web Content Accessibility Guidelines.For example, check if the images on a Web page include ALT properties, required by the W3C Web Content Accessibility Guidelines. Accessibility checkpoints are supported for the Web add-in environment
QuickTest can check that a text string is displayed in the appropriate place in an application or on a Web page with Text Checkpoint. Text checkpoints are supported for the Web add-in environment, plus some Web-based add-in environments Page Checkpoint checks the features of a Web page. For example, you can check how long a Web page takes to load or whether a Web page contains broken links. A page checkpoint can also be created by inserting a standard checkpoint on page object. Page checkpoints are supported for the Web add-in environment
The contents of a database accessed by your application can be checked by Database Checkpoint. Database checkpoints are supported for all add-in environments
By adding XML checkpoints to your test, you can check the contents of individual XML data files or documents that are part of your Web application. The XML Checkpoint option is supported for all add-in environments.

VBScript Code | Appending text to File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.

VBScript Code - The following code appends a text to a file. If the file does not exist, it creates the file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForAppending, True)
QTPfile.WriteLine("Myfirst line of text.")
QTPfile.Close

HP Quicktest VBScript Palindrome

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.

VBScript Code - Finding whether a string is Palindrome or Not.

x=Inputbox("Enter a string")
if x= strreverse(x) then
Msgbox "Its a Palindrome"
else
Msgbox "Its not a Palindrome"
End if

VBScript Code | Reading all lines from File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.
VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForReading , False)

While not QTPfile.AtEndOfStream
a=QTPfile.ReadLine
Print a
Wend

VBScript Code | Reading text from File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.
VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForReading , False)
a=QTPfile.ReadLine
QTPfile.Close
Print a

QTP 11.0 Complete List of New Features

Here I am presenting a complete list of features which are available in the newly launched HP Quicktest Professional 11.

1. Syntax Hints for Regular Expressions

It is now easy to create regular expressions taking help of syntax hints. Regular expression evaluator is available in QTP 11 to test Regular expressions which you have created.

2. Visual Relation Identifiers: Identify objects in relation to other objects

HP R&D team has looked beyond the unreliability of ordinal identifers and come up with a new feature called Visual Relation Identifiers. Ordinal identifers hold good only as long as the relative positions of objects are maintained but if this position changes, the object identification fails.

According to HP Team

"A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application. You can select neighboring objects that will maintain the same relative location to your object, even if the user interface design changes. You define visual relations in the Visual Relation Identifier dialog box, which is accessible from the local or shared object repository, and from the Object Properties dialog box."
3. Recording on Firefox Browser

The much anticipated feature ie recording on Mozilla Firefox browser is now available.

4. Load Function Libraries at Run Time

With the help of LoadFunctionLibrary statement. You can now load a function library when a step runs instead of at the beginning of a run session.

5. Much Awaited Log Tracking is available now

HP QTP 11 is nowcapable of receiving Java or .NET log framework messages from your application which can then be embedded in the QTP run results.

6. Managing Test Data

QTP 11 now boasts of an improved test data management on integrating with HP Quality Center.

7. XPath and CSS based object identification

Identify objects not only using normal object identification but with XPath and CSS identifier properties. This is a much awaited and a great feature.

8. Good Looking and Enhanced Results Viewer

HP team has now created a very good looking and some advanced Results viewer in QTP 11. The new improved results viewer provides an executive summary page with summary data, pie charts and statistics for both the current and previous runs and a quick link to the previous run results.

9. WPF and Silverlight Add-in Extensibility SDK
It enables you to develop support for testing third-party and custom WPF and Silverlight controls that are not supported out-of-the-box by the relevant QuickTest add-ins.

10. Embed/Run Javascript in web pages

You can use the new EmbedScript/EmbedScriptFromFile and RunScript/RunScriptFromFile functions to embed JavaScripts in all loaded browser pages and frames or to run JavaScripts in specific pages.

11. Extensibility Accelerator for QuickTest Professional

It provides a Visual Studio like IDE that accelerates and facilitates the design, development and deployment of QuickTest Web add-in extensibility support sets. These support sets extend the web add-ins so that you can test web controls that are not supported out of the box.

12. Automatically Parameterize Steps

You can instruct QTP 11 to automatically parameterize test steps at the end of record session.

VBScript Code | Writing text to File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.
VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForWriting, False)

QTPfile.WriteLine(" This is my demo text")
QTPfile.Close

QTP Environment Variables Lost

I got a query from one of my esteemed readers which is shown below:

Query:

I am using QTP 10.0 with .NET Addin

I load environment variable from external file using
Environment.LoadFromFile
and this statement is the very first statement in my function library
and When QTP is executed it runs fine loading all environment variables
now after script has run through some time I pause QTP script for some time
and then continue script execution
Now I see that all the environment variables are lost
Note that this does not happen for If my QTP action code has few number
of lines of code
but If my QTP Action code contains more than 800 lines of code I observe this issue
has anyone observed such issue Huh?
Could someone comment if there is any patch Available to resolve this issue ??

##########################################################

Resolution: As far as this query is concerned, this is definitely a performance issue with QTP and should be raised to the HP team

I would like to know has anyone else faced this type of issue before!!

QTP Tip | Capture Application Screenshot during Execution

We can certainly capture application screenshots during execution. Use "Capturebitmap" method to accomplish this. For details please refer to QTP help.

QTP Tip | Disable QTP Results Report

There is definitely a way to disable the QTP results report which means no result file would be created even after the execution. This is certainly different from turning off the option "View results when the run session ends"

The solution for this is very simple. Go to Regedit and browse the key

HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Logger\Media\Report

Change value of Active from 1 to 0 :)

QTP Tip | Include Action In a Function

Question: Is there any way we use Reusable Actions in a specific function located in the function library?

Answer: Yes it is possible. You can insert the RunAction or LoadAndRunAction (QTP 10 or higher versions) statement inside your function.

The following code will illustrate the concept:

###############################################################

'Library
Function Test()
RunAction "My Action", oneIteration
End Function

'Action or Library
Call Test

QTP Tip | Reduce Object Repository Size

Question: Is there any way to reduce the Object Repository size in HP Quicktest Professional 11. I know that Descriptive Programming is one option. Is there any other way to do this?

Answer: You can export the XML file and then delete extra information that QTP stores about the object. This will definitely not allow QTP to perform smart identification. But your script can still recognize the objects present in the application.

QTP Performance Issue

am presenting a scenario for you to think on

#################################################################

I am using HP Quicktest Professional 11. My one Test Script makes call to around 30 External actions. (it uses most of them in one run)

When I modify a cell in one tab of the Datatable (of the 30 tabs referencing the 30 external actions in my script) and attempts to save the script, it takes so long; sometimes close to 45 seconds upto 1 minute.
If I try to open this kind of script, again it takes this much amount of time.

a) Does that mean QTP always try to save the 30 'Default.xls' files in addition to the one 'Default.xls' file that has been modified?
b) Should QTP not save just the one 'Default.xls' file that has been modified?

Note:
All the actions in my Test Script uses only the Descriptive Programming.

How to verify if Browser Window is already maximized

QTP Code:

hwnd = browser("creationtime:=1").GetROProperty("hwnd")

Msgbox window("hwnd:=" & hwnd).getroproperty("maximized")

However, this code won't work with IE7.

QTP Tip | Difference between micclass & micClass

Technically speaking there is no difference. You can try this code out to see it

Code:

obj("micClass").Value="Link"

MsgBox obj("micclass").Value

But for some very rare cases it has been observed that using micClass instead of micclass throws an error when calling ChildObjects.

QTP Recovery Scenario

QuickTest Professional Recovery Scenarios are summarized in the below mentioned points with three "easy to understand" examples.

1) With "Recovery Scenario Manager" you can

a) create and edit recovery files,
b) create and manage the recovery scenarios stored in those files.

2) A unique icon corresponds to a recovery scenario that indicates its type.

3) Each recovery scenario is represented by an icon that indicates its type.

4) You are guided step-by-step, through the process of creating a recovery scenario by Recovery Scenario Wizard.

5) You start by defining the trigger event. [4 trigger types are there Pop-up window, Object state, Test run error, Application crash]

6) After that you specify the recovery operation(s) [Recovery Operation can be Keyboard or mouse operation, Close application process, Function call, Restart Microsoft Windows]

When using Function call, Functions have to be defined using a prototype syntax, which is different for each trigger type.(See QTP User Guide.)

7) Then you select a post-recovery test run operation. [Which can be Repeat current step and continue, Proceed to next step, Proceed to next action or component iteration, Proceed to next test iteration, Restart current test run, Stop the test run]

8) The recovery file is saved in the specific location with the file extension .qrs.

9) Properties for any defined recovery scenario can be viewed from Recovery Scenario Properties dialog box

10) During the run session, QuickTest ignores deleted recovery scenario that is associated with a test or component.

11) You can copy recovery scenarios from one recovery scenario file to another.

12) The scenarios can be prioritized so that QuickTest applies the scenarios during the run session in a order of priority.

13) Some or all of the scenarios can be disabled.

14) Recovery Scenario(s) can be set as default for all new tests.

15) Go to File > Settings, the Test Settings dialog box opens. Select the Recovery tab.

You can edit a recovery scenario file path by clicking the path once to highlight it, and then clicking it again to enter edit mode.

16) In the Recovery tab itself you can define when the recovery mechanism is activated:

On every step.
On error
Never.

17) You can use the Recovery object to control the recovery mechanism programmatically during the run session.

Functional Test Automation Life Cycle

Functional Test Automation life cycle Methodology comprises 11 main phases:

1. Decision to automate testing: it is not that, directly we can kick-start automation for any project/AUT. The Test Manager and client has to take the deicison on whether to go for Test Automation or not. First, the need for Test Automation for the current project has to be determined considering the current status and future plan of the project. During that phase a Cost-Benefit Analysis has to be performed, during which the ROI(Return-On-Investment) has to be calculated and when the ROI is positive and considerable in acceptable time frame, the automation for the project can be given a nod.

2. Acquisition of Testing Tool: Once the decision has been made to go for automation, then the tool to automate the manual test cases has to be decided based on analysis of all the available tools in the market. There are several factors to consider like capability of the tool, compatability of the tool with the application, cost and ease of automation- design, execution and maintenance. If the tool is an easy to learn one then the aspect of "Availability of skilled resources" which we discussed earlier can be waived off as the available resources can be trained to make them skillful to work on the project.

3. Automation test planning: Once the Automation and tool are decided, the most important phase is the Test Planning Phase. This is the phase where the Test Manager/Automation Lead along with the client, has to plan on how to automate, what to automate, when to automate and who to automate. This phase also included the plan for the creation of Automation framework. The framework needs to be designed based on the need and scope of the project.

4. Set-up the automation environment: When the plan is ready, then the environment needs to be setup. This includes several activities like creating the application environment for automation similar to Dev-Environment and QA-environment. Sometimes due to budget/ any other constraint, a separate application environment for automation may not be available. In such cases, the QA-environment is used for automation. But, it is always a best practice to create a separate test data for automation so as not to interfere with regular manual testing activities. This phase also involves the formation of the team, necessary trainings and making the required test wares available.

5. Design the Automation framework: The automation framework is designed in this phase so as to carry on the automation script development, integration, execution and maintenance activities at ease.

6. Design/development of test scripts: Automation scripts are created in this phase/

7. Review and rework of test scripts: This is one of the most important phases, which is neglected by many. Each and every test script has to be reviewed with the help of an optimal checklist and by entering the review comments in a pre-defined review template. Once the review is completed, appropriate rework needs to be done implementing the review comments.

8. Integration of test scripts: All the scripts created by the Automation team are integrated in order to be executed during the execution phase.

9. Execution of test scripts: Test scripts are executed in this phase either by the Automation team or the manual testers.

10. Analysis of test results: Test results are analysed after execution.

11. Enhancement of test scripts(Maintenance Phase): Some of the test scripts may need to be updated depending on the change in the functionality for a particular version/build/release of the application and sometimes test scripts may need to added if new functionality is included in the application. Again, review comes into picture, followed by rework and so on.

QTP 10.0 Installation Guide

The installation of QTP is very easy. You just need to click on the setup.exe application and provide the appropriate license information when asked for. The installation process is very user friendly.

Initially or after the installation process, you need to install Microsoft Script Debugger on your machine where QTP is installed. Installation of Microsoft Script Debugger enables some of the features of QTP.

Introduction to Quicktest Professional 9.2

Quicktest Professional is a Functional Test Automation tool. It is a GUI testing tool from HP Software(originally created by Mercury Interactive Corporation) that allows the automation of user actions on several web based and client based applications developed with a variety of technologies.

QTP was developed by combining the features of Astra Quicktest and Mercury Interatcive Winrunner. Few years ago, Mercury Interactive acquired Astra Quicktest and of course, later, HP(Hewlett Packard) acquired Mercury Interactive. So, QTP is now HP software. Hence it is called "HP Quicktest Professional" from the version 9.5.

QTP used a scripting language built of top of VB Script(Visual Basic Script) to specify the test procedure and to manipulate the objects and controls of the AUT(Application under test).

QTP Overview

  • QTP deploys the concept of keyword-driven testing to enhance test creation and maintenance.
  • Keyword-driven testing is a technique that separates much of the programming work from the actual test steps so that the test steps can be developed earlier and can often be maintained with only minor updates, even when the application or testing needs a significant change.
  • QTP brings non-technical subject matter experts into the quality process in a meaningful way.
  • QTP is widely used for regression test automation.
  • QuickTest Professional is Unicode-compliant and supports Unicode 2.0, UTF-8 and UTF-16.
  • Quicktest Professional supports working with Winrunner( HP no longer sells Winrunner), Quality Center, Business Process Testing and Loadrunner softwares.
By deafult, Quicktest Professional enables you to test
  • Standard Windows applications
  • Web objects
  • ActiveX controls
  • Visual Basic Applications
You can also acquire additional Quicktest add-ins for a number of special environments(such as Java, Oracle, SAP Solutions, .NET Windows and Web Forms, Siebel, PeopleSoft, Web services and terminal emulator applications.

QTP versions: From the past many years, several versions of QTP have been launched. They are QTP 6.0, 6.5,8.0,8.2,9.0,9.1,9.2,9.5 and 10.00. Amond all of these, QTP 8.2 and QTP 9.2 are very successful and are used for most of the Test Automation projects.
QTP 9.5 was launched in Feb 2008 and QTP 10.0 was launched in Feb 2009.

QTP Test Object Model

Test object Model is a set of object types or Classes that QuickTest uses to represents the objects in our application.
A test object class comprises of a list of properties that can individually (uniquely) identify objects of that class and a set of appropriate methods that QuickTest can record for it.
A test object is an object that QuickTest creates in the test to correspond to (represent) the actual object in the application. QuickTest uses the stored information about the object during the run session to identify and check the object. A run-time object is the real (actual) object in the application or Web site on which methods are performed during the run session.
Properties and methods of objects:
The property set for each test object is created and maintained by QuickTest. The property set for each run-time object is created and maintained by the object architect (creator) (Microsoft for Internet Explorer objects, Netscape for Netscape objects).
Similarly, methods of test objects are methods that QuickTest recognizes and records when they are executed (performed) on an object while we are recording, and that QuickTest executes when the test or component runs. Methods of Run-time object are the methods of the object in theapplication as defined by the object architect (creator). We can access and execute run-time object methods using the Object property.
Some important points to remember about methods and properties :

  • Each test object method we execute (perform) while recording is recorded as a separate step in the test. When we run the test, QuickTest executes (performs) the recorded test object method on the run-time object.

  • Properties of test object are captured from object while recording. QuickTest uses the values of these properties to identify runtime objects in the application during a run session.

  • Property values of objects in the application may change .To make the test object property values match the property values of the run-time object, we can modify test object properties manually while designing the test or component or using SetTOProperty statements during a run session. We can also use regular expressions to identify property values.

  • We can view or modify the test object property values that are stored with the test or component in the Object Properties or Object Repository dialog box.

  • We can view the syntax of the test object methods as well as the run-time methods of any object on our desktop using the Methods tab of the Object Spy.

  • We can retrieve or modify property values of the TEST OBJECT during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View. We can retrieveproperty values of the RUNTIME OBJECT during the run session by adding GetROProperty statements. If the available test object methods or properties for an object are not sufficient or they do not provide the functionality we need, we can access the internal methods and properties of any run-time object using the Object property. We can also use the attribute object property to identify Web objects in the application according to user-defined properties.

  • QTP Testing Process

    QTP (QuickTest Professional) lets you create tests and business components by recording operations as you perform them in your application.
    Test - A compilation of steps organized into one or more actions, which we can use to verify that our application performs as expected. A test is composed of actions (3 kinds of actions are there in QTP Non-reusable action, Reusable action and External action).
    1) First step is Planning Before starting to build a test, you should plan it and prepare the required infrastructure.
    For example, determine the functionality you want to test, short tests that check specific functions of the application or complete site.
    Decide how you want to organize your object repositories.
    2) Second step in QTP is Creating Tests or Components
    We can create a test or component by
    a) Either recording a session on your application or Web site.
    As we navigate through the application or site, QuickTest graphically displays each step we perform as a row in the Keyword View. The Documentation column of the Keyword View also displays a description of each step in easy-to-understand sentences. A step is something that causes or makes a change in your site or application, such as clicking a link or image, or submitting a data form.
    OR
    b) Build an object repository and use these objects to add steps manually in the Keyword View or Expert View. We can then modify your test or component with special testing options and/or with programming statements.
    3) Third step is Inserting checkpoints into your test or component.
    A checkpoint is a verification point that compares a recent value for a specified property with the expected value for that property. This enables you to identify whether the Web site or application is functioning correctly.
    4) Fourth step is
    Broaden the scope of your test or component by replacing fixed values with parameters.
    To check how your application performs the same operations with different data you can parameterize your test or component.
    When you parameterize your test or component, QuickTest substitutes the fixed values in your test or component with parameters
    Each run session that uses a different set of parameterized data is called an iteration.
    We can also use output values to extract data from our test or component. An output value is a value retrieved during the run session and entered into the Data Table or saved as a variable or a parameter. We can subsequently use this output value as input data in your test or component.
    We can use many functional testing features of QuickTest to improve your test or component and/or add programming statements to achieve more complex testing goals.
    5) Fifth step is running the test
    After creating test or component, we run it.
    Run test or component to check the site or application.
    When we run the test or component, QuickTest connects to your Web site or application and performs each operation in a test or component, checking any text strings, objects, or tables you specified. If we parameterized the test with Data Table parameters, QuickTest repeats the test (or specific actions in your test) for each set of data values we defined.
    Run the test or component to debug it.
    We can control the run session to identify and eliminate defects in the test or component. We can use the
    Step Into,
    Step Over,
    And Step Out
    commands to run a test or component step by step.
    We can also set breakpoints to pause the test or component at pre-determined points.
    We can view the value of variables in the test or component each time it stops at a breakpoint in the Debug Viewer.
    6) Sixth step is analyzing the results
    After we run test or component, we can view the results.
    ➤ View the results in the Results window.
    After running the test or component, we can view the results of the run in the Test Results window. We can view a summary of the results as well as a detailed report.
    ➤ Report defects identified during a run session.
    If Quality Center is installed, we can report the defects fond out to a database. We can instruct QuickTest to automatically report each failed step in the test or component, or we can report them manually from theTest Results window.

    What is QTP

    QTP (QuickTest Professional) is HP's advanced keyword-driven testing solution. QTP (QuickTest Professional) provides for functional test and regression test automation.
    With QTP (QuickTest Professional) you will be able to test
    • Standard Windows applications
    • Web objects,
    • ActiveX controls, and
    • .Net
    • Java
    • SAP (Systeme, Anwendungen und Produkte in der Datenverarbeitung, Systems, Applications and Products in Data Processing)
    • Visual Basic applications.
    • Siebel
    • Oracle
    • PeopleSoft and
    • Terminal emulators ( http://www.emtec.com/zoc/terminal-emulator.html)
    We need additional QuickTest add-ins for special environments e.g. .Net, Terminal emulators. The current version of QTP (version 10.0) supports running tests on the following browsers:
    . Microsoft Internet Explorer 6.0 Service Pack 1 or 7.0 Beta 2 and lower,
    . Netscape Browser 8.0
    . Mozilla FireFox 1.5.
    QuickTest Professional 9.2 is compatible with: SAP 8.2, .NET 9.2, Web Services 9.2, Java 9.1, Oracle 8.2, PeopleSoft 8.2, Siebel 8.0, Stingray 8.2, Terminal Emulator 8.0, and VisualAge Smalltalk 8.2.
    QTP (QuickTest Professional) is Unicode compliant according to the requirements of the Unicode standard, enabling you to test applications in many international languages.
    As and when an application under test changes, such as when a "Log in" button is renamed "Sign Into," we can make one update to an XML-based Shared Object Repository (within the new Object Repository Manager), and the update will circulate (propagate) to all tests that reference this object. QuickTestProfessional keeps object-level changes synchronized among users throughout test creation efforts.

    Descriptive Programming QTP Tutorial

    Whenever you record on any object using QTP, QTP adds the test object to the Object Repository. While running a test, QTP finds the object in the Object Repository and uses the stored test object’s description to identify the object in your application/website. Only after the object is found in the Object Repository, QTP can perform methods on those objects.
    We can also instruct QTP to perform methods on objects without referring to the Object Repository. This is possible with the help of Programmatic descriptions or descriptive programming.
    This implies that descriptive programming is very helpful if you want to perform an operation on an object that is not stored in Object Repository.
    Descriptive Programming is also useful to perform the same operation on several objects with certain matching properties e.g. suppose there are 8 check boxes on a web page with names as chk_1, chk_2 and so on. So it’s not a good idea to put these in an Object Repository. With the help of Descriptive Programming you can Set these check boxes ON or OFF according to your application needs.
    If you are dynamically creating test objects during the run session then also Descriptive Programming goes a long way to help you. Suppose in a web site you have to generate a list of all the customer's email addresses, who brought iPhone from you, based on the geographical information you provided and then after the email addresses are provided as checkboxes you have to send a rebate letter to them. You don't know how many check boxes will be there based on the geographical information you provided. So in this case, you can use a Descriptive programming to instruct QTP to perform a Set "ON" method for all objects that fit the description: HTML TAG = input, TYPE = check box.
    Descriptive programming can be done in two ways:
    Static: We provide the set of properties and values, that describe the object, directly.
    Dynamic: We have to add a collection of properties and values to a description object and then provide the statement with the description object's name.
    Static is easier but Dynamic provides more power, efficiency, and flexibility.
    We will see examples of both static and dynamic type of descriptive programming in QTP.
    First let’s take a look at Static:
    This below example uses Descriptive Programming to open Flight Application and does not use object repository at all. So one of the other advantages is you can copy this script and Run this from any other machine (other than on which it was created) and it is supposed to work fine.
    For this time just read the script and move on, you will better understand it as you read more.
    [ I have given Example 1a's recorded version (which uses Object Repository)in Example 1b just for your comparison of the two so that you can better understand both ]
    Example 1a: uses DP
    We can describe the object directly by specifying property: =value pairs.
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    window("Title:=Login").WinEdit("AttachedText:=Agent Name:").Set "sachin"
    window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"
    window("Title:=Login").winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Examle 1b: uses OR
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
    Dialog("Login").WinEdit("Agent Name:").Set "sachin"
    Dialog("Login").WinEdit("Agent Name:").Type micTab
    Dialog("Login").WinEdit("Password:").SetSecure "476a9c021bc5a7422cf5a84ad08503823abcbaae"
    Dialog("Login").WinButton("OK").Click
    Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

    Note: When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onwards within the samestatement . If you specify a test object by its object repository name after other objects in the hierarchy have been specified using programmatic descriptions, QTP cannot identify the object.
    For example, you can use the following statement since it uses programmatic descriptions throughout the entire test object hierarchy:
    Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Testing"
    Above line uses Descriptive Programming for all objects like Browser, Page, WebEdit.
    You can also use the statement below, since it uses programmatic descriptions from a certain point in the description (starting from the Page object description):
    Browser("Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Testing"
    Above line uses Object Repository for Browser object and Descriptive Programming for Page and WebEdit.
    However, you cannot use the following statement, since it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the WebEdit test object:
    Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours"). WebEdit("Author").Set "Testing"
    QTP tries to locate the WebEdit object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions.
    If the same programmatic description is being used several times then we can assign the object to a variable:
    E.g. in the above Example 1a script, window("Title:=Login") is being used several times so we do this:
    Set var = window("Title:=Login")
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    var.WinEdit("AttachedText:=Agent Name:").Set "
    Testing"
    var.WinEdit("AttachedText:=Password:").Set "mercury"
    var.winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Or
    We can use 'With & End With' Statement like below:
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    With window("Title:=Login")
    .WinEdit("AttachedText:=Agent Name:").Set "
    Testing"
    .WinEdit("AttachedText:=Password:").Set "mercury"
    .winbutton("Text:=OK").Click
    End with
    window("Title:=Flight Reservation").close

    Now let’s take a look at the dynamic type:
    Understand it like this – A Property Object is a property name and value. We use Description object to return a Properties collection object containing a set of Property Objects. Then only in place of an object name, returned properties collection, can be specified in a statement.
    For creating Properties collection "Description.Create" statement is used.
    Set Myvar = Description.Create() Once Property Object (Myvar) is created, statements to add, edit, remove and retrieve properties and values to or from properties objects can be entered during the run time.
    Lets take a complete example of this: [these extra values (height & width) are not important in our example. Our example can run without height and widthproperties. I have just added those in order to make you understand this]
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    window("Title:=Login").WinEdit("AttachedText:=Agent Name:","height:=20","width:=119" ).Set "
    Testing"
    window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"
    window("Title:=Login").winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Now modifying the above script using Description.Create.
    Set myvar= description.Create()
    myvar("AttachedText").value="Agent Name:"
    myvar("height").value=20
    myvar("width").value=119
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    window("Title:=Login").WinEdit(myvar ).Set "
    Testing"
    window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"
    window("Title:=Login").winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Retrieving child objects in Descriptive Programming:
    There is a ChildObjects method which can be used to get all objects located within a specific parent object or only those that match some criteria for programmatic description. In short we first of all need to create a description and then use a particular syntax to retrieve all child objects that match that description and manipulate them according to our own wish.
    I will straightway show you an example of how to do this:
    Make sure that Flight Reservation window is open (Start- Programs- QuickTest Professional- Sample Applications- Flight). In this Flight reservation window go to File- Open Order.
    We will use this childobjects method to count the checkboxes in this 'Open Order' dialogbox.In the below script childobjects method is being applied to dialog object and childobjects method uses mydescription property object we created.
    Set mydescription=Description.Create()
    mydescription("Class Name").value="WinCheckBox"
    Set Checkboxes = window("text:=FLight Reservation").dialog("text:=Open Order").ChildObjects(mydescription)
    a=Checkboxes.count
    msgbox(a)

    Just try to understand the above code. This is just an example, in real life you can use this count in some kind of loop.
    Creating checkpoints programmatically:
    Run-time value of a specified object property can be compared with expected value of that property by using programmatic description.
    Descriptive programming checks are helpful for the object whose properties you want to check but the object is not stored in Object Repository.
    I will show a small example here which checks if the "Flights.." button in Flight Reservation window is enable or disable. I have used a message box to show whether it is enable or disable, you can use the Report.ReportEvent Statement to send the results to the result window of QTP.
    For the below script make sure that Flight reservation window is open:
    a=window("Title:=Flight Reservation").winbutton("Text:=FLIGHT").GetROProperty("enabled")
    msgbox (a)
    If a = True Then
    msgbox ("button is enable")
    else
    msgbox ("button is disable")
    End If

    In the above script GetROProperty method is being applied to 'Flight..' button to check the 'enable' property of the button.
    [you can see an object's properties and methods from QTP help. Definitely there are other ways also to get these].
    DP is also useful in case of programming WebElement objects (A WebElement is a general web object which can represent any web object.)
    As an example, just open the website (http://newtours.demoaut.com/) and make sure the cursor is in the “User Name” text box and write the following line in the Expert View of new test:
    browser("title:=Welcome: Mercury Tours").page("title:=Welcome: Mercury Tours").webelement("name:=password","index:=2").Click
    It will just click the “Password” text box which just highlights that text box and places the mouse cursor in that box.
    For all the methods and properties of WebElement object please refer QTP User Guide.
    Index property
    Index property is useful to identify a test object uniquely. QTP also, while learning an object, can assign a value to test object’s index property to uniquely identify it. Index property values are specific to an object and also the value is based on the order in which the object appears in the source code.
    The value starts with 0.
    If you use Index:=1 with WebEdit test object, QTP will search for the second WebEdit object on a web page.
    As an example, just open the website (http://newtours.demoaut.com/) and write the following line in the expert view of new test:
    browser("title:=Welcome: Mercury Tours").page("title:=Welcome: Mercury Tours").WebEdit("Index:=1").Set "hello"
    This will write “hello” in the “Password” text box. In the above line if you do Index:=0 then “hello” will be written in the “User Name” text box.
    On the other hand if you use Index:=2 to describe a WebElement object, QTP will search for the third object on the page (it can be any, regardless of type) because WebElement object is general object that applies to all objects.
    Last but not the least SystemUtil object
    SystemUtil object allows you to open and close application by writing its code manually in the Expert view of QTP.
    Below example shows how to open or close a Notepad using code:
    systemutil.Run "Notepad.exe"
    wait(3)
    SystemUtil.CloseProcessByName("Notepad.exe")

    This example uses Run and CloseProcessByName methods to open and close the application (Notepad). Instead of closing the Notepad with CloseProcessByName method, we can use the below line also which is mostly used.
    window("title:=Untitled - Notepad").Close
    For opening the application we can use complete paths also e.g.
    systemutil.Run "C:\Program Files\Internet Explorer\iexplore.exe"
    This opens an Internet explorer.