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.