Monday, October 13, 2008

QTP9.2


QTP (QuickTest Professional)
Mercury is the world leader in application delivery, with 58.8-percent market share in automated software quality and performance testing products.
QuickTest Professional is most suitable Automation Software Testing Tool in this fast changing software development world.
Mercury QuickTest Professional: provides the industry's best solution for functional test and regression test automation - addressing every major software application and environment.
Points worth noticing about QTP:
1. As QTP is relatively easy to use, an organization has to spend minimal time, money and effort in training its employees on QTP.
2. QTP allows you to do regression testing with ease on repeatedly changing applications and environments.
3. QTP allows sharing automated testing assets, functions, and objecting repositories enabling an organization to deliver quality products and services, and improve revenues and profitability.
QTP can be integrated with WinRunner, Load Runner, and Test Director.

What is QTP (QuickTest Professional)?
QTP is Mercury's advanced keyword-driven testing solution. QTP provides for functional test and regression test automation.
With QTP you will be able to test
Ø Standard Windows applications
Ø Web objects
Ø ActiveX controls
Ø .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 9.x) 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. QuickTest Professional keeps object-level changes synchronized among users throughout test creation efforts.
Moreover, now users can invoke and run Mercury WinRunner™ scripts and functions from Mercury QuickTest Professional, and then automatically report WinRunner results back into the original scripts.

QTP Test Pan
QTP Test Pane contains the
1. Expert View
2. Keyword View
3. Data Table
4. Active Screen etc….

QTP (QuickTest Professional) keyword view
In QTP 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.
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 –
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.

Testing Process of QTP
QTP 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 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 Parameterization:
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 the Test Results window.
QTP (QuickTest Professional) Recording:
The default mode of recording is the Normal recording mode. There are otherrecording 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
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

Checkpoints in QTP (QuickTest Professional)
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 ifneeded.
Types of Checkpoints:
Ø Standard checkpoint
Ø Image checkpoints
Ø Bitmap Checkpoint
Ø Table checkpoints
Ø Accessibility Checkpoint
Ø Text Checkpoint
Ø Page Checkpoint
Ø Database Checkpoint
Ø 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. Forexample 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, andOther 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
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
Table checkpoints: 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
Text checkpoints: 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
Database Checkpoint: The contents of a database accessed by your application can be checked by Database Checkpoint. Database checkpoints are supported for all add-in environments
XML checkpoints: 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.
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:
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

Explain Test object Model, test object and run-time object?
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.
Test Object Class

Properties Methods
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 the application 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 retrieve property 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.


Object Repositories in QTP 9 (QuickTest Professional)
An object as we know is a graphic user element in an application e.g. a button or a list or an edit box and the special characteristics of an object within the QuickTest are called “Object Properties”. QTP stores the recorded object properties in “Object Repository”.
Object Repositories are of two types Local and Shared.
Ø If objects are stored in a Local Object Repository then these are available to specific actions but not to all the actions. But if these objects are stored in one or more Shared Object Repositories then multiple actions or tests can use them.
Ø By default QTP makes and uses Local Object Repository. If we create a new blank test and do a recording on it, QTP automatically creates a Local Object Repository for that test or action and stores the information about any object it finds in that corresponding Object Repository.
Ø In QTP 9 we can associate multiple Shared Object Repositories with an action. If multiple Shared Object Repositories are associated with an action then also while recording QTP stores objects in corresponding Local Object Repository on the condition that those objects are not already stored in any corresponding associated Shared Object Repositories.
Ø This is the default that every time we create a new action QTP creates a new corresponding Local Object Repository. It is also true that Object Repositories are associated with actions and no matter how many times we learn or record on the same object in our application in different actions the object will be stored as separate test object in each of the Local Object Repository. Local Object Repository is automatically saved with the test when we save it.
Ø The extension of the Local Object Repository is .mtr, For Shared Object Repository .tsr
Ø We can also manipulate some aspects of Local Object Repository using Quick test Object Repository Automation Object Model.For example we can add, remove, rename test objects in Local Object Repository. [QuickTest Object Repository Automation documents the Object Repository automation object model that enables you to manipulate QuickTest object repositories and their contents from outside of QuickTest.]
Ø When we open a test that was created using a version of QTP earlier that version 9 we are asked whether we want to convert it or view it in read only format. In any case if the test previously used per-action Object Repository, the objects in each per action repository are moved to the Local Object Repository of each action in the test.
Ø If the test previously used a shared object repository, the same shared object repository is associated with each of the actions in the test, and the local object repository is empty.
Ø While learning or recording we can specify Shared Object Repository for the selected action. We can specify and associate one or more Shared Object Repositories with each action. We can also create new Shared Object Repository and associate it with our action.
Ø In case of Shared Object Repository, QTP uses existing information and does not add objects to the Object Repository if we record operations on an object that already exists either in Shared or Local Object Repository.
Ø As said earlier QTP does not add objects directly to the associated Shared Object Repository as we record, instead it adds new objects in Local Object Repository (if that object does not already exist in associated Shared Object Repository).
We can surely export Local objects to Shared Object Repository.
There are different ways in which we can move objects from Local Object Repository to Shared Object Repository:
1) Exporting the objects to the Shared Object Repository from the Local Object Repository:
In Object Repository window choose the action whose local objects you want to move. Choose File-> Export Local Objects.Select the location in which you want to save the file. Click on save.
2) We can update the Shared Object Repository with the Local Object Repository:
If we create a new test it will be created with Local Object Repository, we can associate any new or old Shared Object Repository with it, and so we can update that Shared Object Repository with Local Object Repository.
In Object Repository Manager open the Shared Object Repository (clear open in read only check box).The test in this case should not be open. In Object Repository Manager go to Tools –> Update From Local Repository. Select the test who's Local Object Repository you want to use. Click update all. It will move all the objects to the Shared Object Repository.
3) We can also merge objects from two Object Repositories (called as primary and secondary in QTP9) into a new single Object Repository (target Object Repository in QTP 9). The original source files are not changed. It also enables you to merge objects from Local Object Repository of one or more action(s) into a Shared Object Repository. It is recommended to use as a primary Object Repository the file in which you have invested alot of your effort, like which has more number of objects.
4) If we do not specify a file extension for Shared Object Repository when creating a new Shared Object Repository QTP automatically appends a default extension name for Shared Object Repository as .tsr.
5) We can compare two Object Repositories using the Object Repository Comparison Tool. The tool enables you to identify similarities, variations or changes between two Object Repositories.
6) We can also copy objects to Local Object Repository from the Shared Object Repository. We can copy, paste and move objects in Local Object Repository and copy, paste and move objects within Shared Object Repository and between Shared Object Repositories.As said earlier we can also copy objects from shared Object Repository to Local Object Repository to modify them locally.We cannot remove an association between the action and its Local Object Repository.
7) Whenever we make any changes to an Object Repository those changes are automatically updated in all the associated tests open on the same computer as soon as we make the change even if the Object Repository is not yet saved and if we close the same Object Repository without saving the changes the changes are rolled back in any open tests. For the test that was not open when we changed Object Repository, when we open the test on the same machine on which we modified the Object Repository the test is automatically updated with all the saved changes. To see saved changes in a test or repository open on a different computer, you must open the test or object repository file or lock it for editing on your computer to load the changes.
Important points about Object Repositories
It is a point to consider while planning and creating test that how you want to store objects; either you want to store them in Local Object Repository or Shared Object Repository.1) For each action, we can also use a combination of objects from the Local and Shared Object Repositories, according to our needs. Local objects can also be transferred to a shared object repository, if necessary. This will cut maintenance and increase the reusability of the tests because it will enable us to maintain the objects in a single, shared location instead of multiple locations.
2) If there is a same name object in both the Local Object Repository and in a Shared Object Repository associated with the same action, the action uses the local object definition i.e. the local object is given preference over the shared object. If an object with the same name is stored in more than one Shared Object Repository associated with the same action, the object definition is used from the first occurrence of the object, according to the order in which the Shared Object Repositories are associated with the action.
3) When we open an existing test, it always uses the object repositories that are specified in the Associated Repositories tab of the Action Properties dialog box or in the Associate Repositories dialog box. When we access Shared Object Repositories from tests they are read-only; we can edit them only using the Object Repository Manager.
4) 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. QuickTest Professional keeps object-level changes synchronized among users throughout test creation efforts.
Object Repository dialog boxObject Repository dialog box window shows a tree of all the objects (either Local or Shared) on its left hand side in the selected action. On selecting any object in the tree Object Repository window shows the information about the object like the name, repository in which it is stored etc. On the left hand side in a tree local objects are editable while the shared ones are grayed out (non-editable).
To view the test object properties, to modify test object properties and to add objects to Local Object Repository we can use Object Repository window. We can also delete objects from Object Repository window; this is needed as when an object is removed form the test it is not automatically removed from the Local Object Repository.
Object Repository in QTP is XML based means that if we change something related to the object in Shared Object Repository., the change will be propagated to all the tests that reference this object, in real time.
Adding Objects to Repositories
Ø We can add objects to Shared Object Repository or Local Object Repository in a number of different ways-We can decide whether to add only a selected object, or to add all objects of a certain type, such as all button objects, or to add all objects of a specific class, such as all WebButton objects.
Ø We can modify objects stored in a Local Object Repository using the Object Repository Window and objects in a Shared Object Repository using the Object Repository Manager.
Ø It is possible to add objects to the object repository before they exist in an application.We can also add objects to the Local Object Repository while editing our test.We can add the object directly to a Shared Object Repository using the Object Repository Manager, so that it is available in all actions that use this Shared Object Repository.If needed, we can merge test objects from the Local Object Repository into a Shared Object Repository.
Ø We can also add objects to a Shared Object Repository while navigating through the application ("Adding Objects Using the Navigate and Learn Option").We can also add an object to the Local Object Repository by choosing it from the application in the Select Object for Step dialog box (from a new step in the Keyword View or from the Step Generator).
Ø We can add objects to the object repository using the Add Objects to Local or Add Objects option.We can add objects to the Local Object Repository of the current action by selecting the required object in the Active Screen.

Actions in QTP 9 (QuickTest Professional)
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) levelwithin 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.

Descriptive Programming in QTP
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 1b's recorded version (which uses Object Repository) in Example 1a just for your comparison of the two so that you can better understand both]
Example 1a: uses DPWe 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 "Shiva"window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"window("Title:=Login").winbutton("Text:=OK").Clickwindow("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 "Shiva"Dialog("Login").WinEdit("Agent Name:").Type micTabDialog("Login").WinEdit("Password:").SetSecure "476a9c021bc5a7422cf5a84ad08503823abcbaae"Dialog("Login").WinButton("OK").ClickWindow("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 same statement. 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 "Shiva"
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 "Shiva"
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 "Shiva"
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 "Shiva"var.WinEdit("AttachedText:=Password:").Set "mercury"var.winbutton("Text:=OK").Clickwindow("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 "shiva".WinEdit("AttachedText:=Password:").Set "mercury".winbutton("Text:=OK").ClickEnd withwindow("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 width properties. 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 "Shiva"window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"window("Title:=Login").winbutton("Text:=OK").Clickwindow("Title:=Flight Reservation").close
Now modifying the above script using Description.Create.
Set myvar= description.Create()myvar("AttachedText").value="Agent Name:"myvar("height").value=20myvar("width").value=119SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"window("Title:=Login").WinEdit(myvar ).Set "Shiva"window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"window("Title:=Login").winbutton("Text:=OK").Clickwindow("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.countmsgbox(a)
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 Thenmsgbox ("button is enable")elsemsgbox ("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.
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.
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.
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.

QTP Sync, Wait and Synchronization
Synchronization makes available specified amount of time for an object to process prior to moving on to the next step.
Wait is like forcing the QTP to wait for a specified amount of time while synchronization is not a 'forced' wait e.g. whenever a specific page loads QTP moves forward in case of synchronization, but in case of wait, if the wait is for 10 seconds and a webpage loads in 3 seconds then it still waits for 7 seconds.
Synchronization is there to take care of the timing problems between QTP and the AUT. Examples where synchronization can be used:
For a web page to load.For a button to become enabled or disabled.For client-server communications to finish.
Synchronization is possible in many ways:
1) We can insert a synchronization point for example for a progress bar to reach 100%. QTP will generate a WaitProperty statement in the Expert View in case of synchronization.
2) We can use Exist or Wait statements. Exist statements always return a Boolean (0 or 1) value.
3) We can also modify the default amount of time that QTP waits for a Web page to load.(Browser Navigation Timeout, File(menu)-> Settings-> Web tab)
4) When working with tests, we can increase the default timeout settings for a test to instruct QuickTest to allow more time for objects to appear.(Object Synchronization Timeout, File(menu)-> Settings-> Run tab)
Synchronization is enabled only during recording.
QTP Parameters
This is not an exhaustive material on parameterization. This is just to give you a startup on parameters in QTP, so that you can go ahead and do wonders with parameters in QTP.
· Environment Variables in QTP
· Random Variables in QTP
· Test parameters
· Action Parameter
· Global and Action data sheet Parameters
· QTP Output Values
· Parameterize a checkpoint

QTP Environment Variables
User-Defined Internal, User-Defined External, Built-in are the types of environment variables available in QTP.
Built-in variables as the name suggests are predefined by QTP. Examples of such variables are OS, OSVersion, ActionName which are for Operating System, Operating System Version and name of the action which is currently running, respectively.
Let’s look at an example of this:
1. Open a new Test.
2.Go to File (Menu)->Settings, a Test Settings window opens.
3. Go to Environment Tab. By default Built-in variable type is selected and you will be able to see Name and Description of Built-in variables below Variable type dropdown box.
4. You can click on any of those variables to see their current value.
5. I just did the above four steps in order to show you from where you can access Built-in variables.
6. Now close this Test Settings window and go to test.
7. In the Expert View type:
a = environment("ActionName") & " is running on " & environment("OS")msgbox (a)
8. And Run the test.
It is just a simple way to show how a Built-in environment variable works.
User Defined Internal:variables are the variables defined by you (the user) within the test and which are saved within the test and also accessible from within the test.
Lets look at an example of this:
1. Open a new Test.
2. Go to File (Menu)->Settings, a Test Settings window opens.
3. Go to Environment Tab. From Variable type dropdown select User-defined.
4. Click on the '+' which is on the right of Variable type dropdown.
5. 'Add New Environment Parameter' window opens up, type the name and value of the variable e.g. in Name type 'a' and in Value type 'hello' (without quotes, I have added quotes just for clarity) and click on OK. It will add the variable with its type as 'internal'.
6. Click Apply and OK to come out of Test Settings window.
7. Go to expert view and type:msgbox(environment("a"))
8. Now Run the test. It will show you the value of variable 'a' in the message box.
User-Defined external: variables are the variables which are defined in the file outside of test. These act as read only for the test. You can create as many files for environment variables as you want and choose them for your test.
Now lets look at an example of this:
Open a new text file and type the following lines in it and save it with .xml extension. ( I saved it in 'tests' folder in the 'QuickTest Professional' folder under C:\Program files.)
1. Open a new Test.
2. Go to File (Menu)->Settings, a Test Settingswindow opens.
3. Go to Environment Tab. From Variable type dropdown select User-defined.
4. Click on "Load variables and values from external file" check box and import that external xml file that we created above. As soon as it is imported the complete path of that file will be shown in the File text box and the variable in it will show under Name, Value and Type heading (in our case it will show Address under Name, 25 yellow Road under Value and External under Type).
5. Click on Apply and Ok to come out of it.
6. Go to expert view and type:msgbox(environment("Address"))
7. Now run the test. It will show you the value of variable 'Address' in the message box.
QTP Random Variables
First example of Random Numbers:
When you define parameters for an action you can set the parameter's value as Random numbers. There are many different ways in which you can use Random numbers in QTP. Lets jump at the examples straightway.
Example 1:
1. Open a new test.
2. In the keyword View right-click on Action1, select Action Properties, 'Action Properties' window opens, Go to 'Parameters' Tab.
3. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a', Type as Number, and Default value as 1. Click Ok.
4. Again right-click on Action1 in the keyword View , select 'Action Call Properties', 'Action Call Properties' window opens. Go to 'Parameter Values' Tab.
5. Make a single click under 'Value' column in the 'Input Parameter's' area, it will become a button '<#>'. Click on this button.
6. It will open 'Value Configuration Options' window.
7. Click on 'Parameter' radio button, select 'Random Number' from the dropdown. In the Numeric Range enter 0 against From and 100 against To.
8. Click on Name Checkbox and choose arg_a from the dropdown.
9. In the 'Generate New Random Number' area, select first option-For each action iteration. Click ok.
10. Again Click ok to come out of 'Action Call Properties' window.
11. Now Go to Insert (Menu)-> Call to New Action, 'Insert Call to New Action' window opens, click ok to insert a new action- action2.
12. Go to Expert view of action1 and type:
Msgbox "action1"msgbox (parameter("a"))
13. Go to Expert View of Action2 and type:
For i=1 to 3RunAction "Action1", oneIteration, RandomNumber("arg_a")Next
14. When you copy the above text to Expert View of Action2, it will show you a message that it has made Action1 Reusable, just click ok.
15. Now Run the test.
(It would be better if you run it by activating the expert view, then it will show you which step it is currently running by pointing to that particular step with yellow color arrow and then you will be able to understand it in a better way. You will see that it shows a different value in each msgbox() because we selected 'For each action iteration' from the 'Generate new random number' area. If we select the second option 'For each test iteration' then a messagebox will show same values, but different values if you run it next time i.e. a different value at each test run.)
RandomNumber is an Object.
RandomNumber(ParameterNameOrStartNumber [,EndNumber])
EndNumber is optional above.
Second example of Random Numbers:
Here is another way of generating random numbers:
Open a new test and in the Expert view write these lines and run the test:
For i=1 to 5var1=RandomNumber (0, 100)msgbox(var1)Next

Third example of Random Numbers: (This is more or less same as the first one)
One more way is to define a Random Number parameter in the 'Parameter Options' or 'Value Configuration Options' dialog box.
1. Open a new test.
2. In the keyword View right-click on Action1, select 'Action Properties', 'Action Properties' window opens, Go to 'Parameters' Tab.
3. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a', Type as Number, and Default value as 1. Click Ok.
4. Again right-click on Action1 in the keyword View , select 'Action Call Properties', 'Action Call Properties' window opens. Go to 'Parameter Values' Tab.
5. Make a single click under 'Value' column in the 'Input Parameter's' area, it will become a button '<#>'. Click on this button.
6. It will open 'Value Configuration Options' window.
7. Click on 'Parameter' radio button, select 'Random Number' from the dropdown. In the Numeric Range enter 0 against From and 100 against To.
8. Click on 'Name' Checkbox and choose arg_a from the dropdown.
9. In the 'Generate New Random Number' area, select first option-For each action iteration. Click ok.
10. Again Click ok to come out of 'Action Call Properties' window.
11. Now in the Expert View of action1 type:
x=RandomNumber("arg_a")msgbox(x)
12. And Run the Test.
Fourth example of Random Numbers:
Another VBScript method of generating a random number:
For i= 1 to 3var1 = int((101*rnd)+0) ' Generate random value between 0 and 100.Msgbox var1next
Let's talk about Randomize and Rnd for some time:
Randomize [number]
We use a number with Randomize to initialize the Rnd function's random-number generator, giving it a new seed value. If the number is omitted, the value returned by the system timer is used as the new seed value. In simple terms Rnd is a function and Randomize is used to initialize this function.
If Randomize is not used, the Rnd function (with no arguments) uses the same number as a seed the first time it is called.
No matter how many times you Run the below code it generates the same values:
For i= 1 to 3randomize (2)var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.MsgBox var1next
But if you omits randomize (2) from the above code and instead put only randomize then at each run it generates different values.
For i= 1 to 3randomizevar1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.MsgBox var1next
Some light on Rnd:The following formula is used to produce a random number in a given range:Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
likewiseInt((6 * Rnd) + 1) ' Generate random value between 1 and 6.The Rnd function returns a value less than 1 but greater than or equal to 0.
Rnd (number) If the number is Less than zero (< 0) then Rnd generates 'The same number' every time, using number as the seed.
For i= 1 to 3x=rnd(-1)msgbox(x)Next
If the number is Greater than zero(> 0) then Rnd generates 'The next random' number in the sequence.
For i= 1 to 3x=rnd(1)msgbox(x)Next
If the number is Equal to zero (=0)then Rnd generates 'The most recently generated' number.
For i= 1 to 3x=rnd(0)msgbox(x)Next
If the number is Not supplied then Rnd generates 'The next random number in the sequence.'
For i= 1 to 3x=rnd()msgbox(x)Next
Remember:
For any given initial seed, the same number sequence is generated because each successive call to the Rnd function uses the previous number as a seed for the next number in the sequence.
Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer.
QTP Test parameters
1. Open a New Test.
2. Go to File->Settings, a 'Test Settings' window will open, go to 'Parameters' Tab.
3. Click on '+' sign which is on the top right.
4. Enter the Name of the parameter as 'vartest' and its Default Value as 'hello'. Click Apply and then Ok. The Type of this parameter is string.
5. Above we have created a Test Parameter.
6. Now in the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens.
7. Go to 'Parameters' Tab. Click on '+' sign which is on the top right.
8. Enter the Name of the parameter as 'varaction' and its Type as string and no default value. Click Ok to come out of that window.
9. Again in the Keyword View right click on Action1 and select 'Action Call Properties'. 'Action Call Properties' window opens.
10. Go to 'Parameter Values' Tab. There you will see the 'varaction' action parameter we created earlier. Make a single click under 'Value' heading, it will show a button like this <#>. Just click on this button to open 'Value Configuration Options' window.
11. Click on 'Parameter' radio button and select 'Test/action Parameter' from that dropdown.
12. 'Test Parameters' radio button will be selected by default and under 'Test Parameters' radio button select 'vartest' from Parameter dropdown.[ remember this vartest is a test parameter we created at the beginning]
13. When you click on ok to come out of 'Value Configuration Options' window, in the 'Action Call Properties' window, under 'Value' it will show . Click Ok.
14. Go to Expert View and type:msgbox(parameter("varaction"))
15. Now run the test. While running it will show 'hello' in the msgbox.
This example shows how to declare test parameters and how to access those.
Remember (taken from QTP guide):
You can directly access test parameters only when parameter zing the value of a top-level action input parameter or when specifying the storage location for a top-level output parameter. To use values supplied for test parameters in steps within an action, you must pass the test parameter to the action containing the step. For more information, see Setting Action Parameters.Alternatively, you can enter the parameter name in the Expert View using the Parameter utility object, in the format: Parameter "Parameter Name").

QTP Action Parameter
1. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens.
2. Go to 'Parameters' Tab. Click on '+' sign which is on the top right.
3. Enter the Name of the parameter as 'a' and its Type as Number. In the same way create another Number parameter 'b'.
4. Click Ok.
5. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens. In the general tab, click on 'Reusable Action' checkbox at the bottom to make the action reusable.
6. In the Expert View of Action1 type:
s1=parameter ("a")s2=parameter("b")msgbox(s1+s2)
7. Go to Insert (menu)-> Call to New Action. 'Insert Call to New Action' window opens. Just click ok to insert a new action.
8. Make action2 reusable as we did for action1.
9. In the Expert View of action2 type:
RunAction "Action1", oneIteration, 2,2
10. In the keyword View right click on action2 and select 'Run from Step', it will show you the sum 4 in msgbox.

QTP Global & Action Data Sheet Parameters
Example 1
How, for each row, in global data sheet, QTP iterates all rows of any action data sheet.
1. Open a new Test.
2. Click on Record.
3. Go to Start->All Programs->QuickTest Professional->Sample Applications->Flight.
4. Enter the Agent Name as 'mary' and Password as 'mercury'. Click Ok (make sure we click ok with mouse and not hit the return (enter) Key.)
5. When the Flight Reservation window is open, go to File->Exit.
6. Click Stop in order to stop recording the test.
7. In the Keyword View under 'Value' column, make a single click on 'mary' (Agent Name), a button like <#> will appear, click on this button to open 'Value Configuration Options' window.
8. Click on Parameter radio button and select Data Table from the dropdown and let rest everything be default. click ok to come out of that window.
9. In the Global Data sheet it will add a new columns with 'mary' as its first value.
10. Go to Insert (menu) -> Call to New Action to insert action2.
11. For this action2, repeat steps from 2 to 7. (This time I have used the Agent Name as 'bill')
12. After repeating step 7, when you click on 'Parameter' radio button and select Data Table from the dropdown, make sure you select Current action sheet (local) in the Location in Data Table area. Click Ok to close that window.
13. It will add a new column in action2 Data Sheet with 'bill ' (because I used bill as an Agent Name ) as its first row.
14. Now you have two actions (action1 and action2), both of them do the same job but their data is in different sheets.
15. Go to Global Data Sheet and Add one more row in it below 'mary'. I added 'rama'.
16. In the Local Data Sheet (action2) add two more rows to make them a total of 3. I added 'amar' and 'Sumit'.
17. Right click on action1 and select action call properties, go to Run Tab and select "Run on all rows" radio button. Do the same for action2.
18. Go to Expert View of action one and type : msgbox("acton1"). Now my action1 looks like this:
Dialog ("Login").WinEdit ("Agent Name:").Set DataTable("p_Text", dtGlobalSheet)
Dialog ("Login").WinEdit ("Agent Name :").Type micTab
Dialog ("Login").WinEdit ("Password :").SetSecure “4725bcebeea3b6682d186bf7b15ae92cc4e6c0ba"
Msgbox ("acton1")
Dialog ("Login").WinButton ("OK").Click
Window ("Flight Reservation").WinMenu ("Menu").Select "File;Exit"
19. Do the same for action2 and type msgbox("acton2") in its Expert view, as we did for action1.
20. Now Run the test.
I have added the msgbox step in both the action just to make you understand how the QTP is picking up the rows from Data Sheets, otherwise it will be fast and some people may not able to understand.
Example 2
This examples shows that each action can access data not only from Global Data Sheet or its own Local Data Sheet but also from other action's Data Sheet in the same test.
Open a new test.
Insert two actions.
In the Global Data table, in cell(A,1) type 'Global Data'.In the Action1 Data table, in cell(A,1) type 'Action1 Data'.In the Action2 Data table, in cell(A,1) type 'Action2 Data'.
In Expert View of action1 type:
Msgbox ("I am in action 1")rc = DataTable.Value("A", dtGlobalSheet) 'accessing data from Global data sheet from action1msgbox rcrc = DataTable.Value("A", 2) 'accessing data from action1 data sheet from action1msgbox rc
In expert view of action2 type:
msgbox("I am in action 2")rc = DataTable.Value("A", dtGlobalSheet) 'accessing data from Global data sheetfrom action1 msgbox rcrc = DataTable.Value("A", 2) 'accessing data from action1 data sheet from action2msgbox rc

QTP Output Values
This is a very small tutorial on output values, just to make you familiar with the process so that you can start on your own. For complete understanding of Output values please see QTP User Guide.
1. Open a new test and also open a sample Flight application (Flight Reservation window)
2. Make sure that both (new test and Flight Reservation window) are open and visible.
3. Click on Record in order to record a test.
4. Go to Insert (Menu)->Output Value->Standard Output Value.
5. QTP will be minimized and mouse pointer will take the shape of a hand. Click on 'Insert Order' button in 'Flight Reservation window.'
6. "Object Selection - Output Value Properties" window opens with WinButton :Insert Order highlighted. Click Ok.
7. "Output Value Properties" window opens with 'Insert Order' in the Name text field.
8. Click on first checkbox (which is Property enabled and Value False).
9. In the 'Configure Value' area click on Modify button.
10. 'Output Options' window opens. In this window just click Ok. (It creates Insert_Order_enabled_Out column in Global datasheet in Data Table with a Value False in the first row)
11. It will bring you back to "Output Value Properties" window. Now earlier where under Value it was showing False (see step 8) now it will show Insert_Order_enabled_Out.
12. Again Click Ok to come out of this "Output Value Properties" window.
13. Click Stop in order to stop the test.
14. Now it means whatever the value of Insert Order button's Enable Property will be, QTP will show that value in Data Table (under Insert_Order_enabled_Out column) at Run time.
Just make that Insert Order button enable by putting some values in Flight Reservation window and then see that column (Insert_Order_enabled_Out ) in Data table. It will show a true value in there at run time. It will also show that captured value in the Results window.
These above steps show you how to use output values with Data Table. Below tutorial shows how to use output values with Environment variables.
1. Open a new test and also open a sample Flight application (Flight Reservation window)
2. Make sure that both (new test and Flight Reservation window) are open and visible.
3. Click on Record in order to record a test.
4. Go to Insert (Menu)->Output Value->Standard Output Value.
5. QTP will be minimized and mouse pointer will take the shape of a hand. Click on 'Insert Order' button in Flight Reservation window.
6. "Object Selection - Output Value Properties" window opens with WinButton : Insert Order highlighted. Click Ok.
7. "Output Value Properties" window opens with 'Insert Order' in the Name text field.
8. Click on first checkbox (which is Property enabled and Value False).
9. In the Configure Value area click on Modify button.
10. Output Options window opens.
11. In 'Output Options' window, from 'Output Types' dropdown, select Environment, andclick Ok.
12. Now Insert_Order_enabled_out will be User-Defined internal environment variable.
13. Click Ok to come out of this "Output Value Properties" window. (You can check that environment variable by going to File->Settings, Environment Tab and choosing User-Defined from variable type)
14. Just add the below line in the Expert View at the end to see the value of the environment variable.
Msgbox (environment ("Insert_Order_enabled_out"))
15. Now you can Run the test.
Just make that Insert Order button enable by putting some values in Flight Reservation window and then see that environment variable value (Insert_Order_enabled_Out ). It will show a true value in there at run time. It will also show that captured value in the Results window.
Parameterize a Checkpoint
You can create a Checkpoint while recording or editing a test. For this tutorial I will take into account Text Checkpoint created through Standard Checkpoint while editing.
Open a new test.
Click on Record.
Go to Start-> All Programs->QuickTest Professional->Sample Applications->Flight.
Enter the Agent Name as "Shiva" and Password as "mercury". Make sure you use Tab key to move from one text box to another and hit Return (Enter) key after entering the Password.
When the Flight Reservation window is open Go to File (menu)->Exit.
Click on Stop in order to stop the recording.
In the Keyword view go to the row which has "Shiva" under Value column. Right-click anywhere on that row and choose "Insert Standard Checkpoint."
"Checkpoint Properties" window opens. Make sure only the Text property is checked which has a value of "Shiva" and rest all of the properties must be unchecked.
Just make a single click on Text Property, which you checked above, in order to highlight it and make "Configure Value" area enabled.
In this area click on Parameter Radio button. This is all we need to do.
[On the right hand side of Parameter Radio button you will see Parameter Options button (which has paper and pen image on it). you can click on it to see the default values QTP has set for us.]
In the "Checkpoint Properties" window just click on Ok to come out of it.
It will add a column in the Global Data Sheet with "Shiva" as its first value.
Add two more values in the subsequent rows. I added "aaaa" in the 2nd and "bbbb" in the 3rd.
Now when we run the test and it opens the window where we need to enter the Agent Name and Password, you have to enter Agent Name all of the 3 times (Just enter the Agent Name, that's it, no Tab key or Return key). Make sure you enter "Shiva" during first time, "aaaa" during second time and so on. We don't need to enter the Password. Remember this is a Text Checkpoint on the "Agent Name" Text field. Any value entered there first time will be compared by first row of the Global Data Sheet which has "Shiva" and any value entered there Second time will be compared by second row of the Global Data Sheet which has "aaaa" and so on. Just try to enter some other value during second time like "xxxx" it will run the test but show you "Failed" in the Results window in the second iteration.

Function Library
If you have repeatable steps in a test or an action then consider using a user-defined function. User-defined functions will make your tests look shorter, easier to maintain, read and design. A user-defined function can then be called from within an action.
Time and resources can be saved by implementing and using user-defined reusable functions.
User-defined functions can be stored in a function library or within an action in the test.
User-defined functions can be registered as a method for a QTP test object.
[It is advisable not to give user-defined functions same name as built-in functions (refer to the Built-in functions list in the Step Generator (Insert > Step Generator, in the Step Generator dialog box choose Built-in functions from Library Combo box, it will show all of the Built-in functions in Operation Combo box))]
If the function is stored in a function library then we have to associate that function library to a test so that the test can call all the public functions listed in that library.
Functions in an associated function library are accessible:
From Step Generator (for tests and function libraries),
From the Operation column in the Keyword View, or
Can be entered manually in the Expert View.
Functions directly stored in an action in a test can be call from within that action only making them very private from the outside world.
A Private function can also be created in a function library and this private function can only be called from within the function library itself in which it is defined.
Functions can be created manually or by using Function Definition Generator.
It is easy to create a function library:
Open a new function library file->New->Function library).
Add content to it (your function). Associate it with a test (File-> Associate Library with Test).
Many different function libraries can be opened simultaneously as each opens in its own separate window and you can work on them separately.
If a test is open you can view all the function libraries associated with it. (Resources->Associated Function Libraries.)
You can save function library either from File->Save or right click on function library tab on the top of function library and choose save.
Some important points regarding function libraries.
When we register a function, it applies to an entire test object class and it’s not possible to register a method for a specific test object.
If we use options like Run from step or Debug from step, tobegin running a test from a point after method registration was performed in atest step (and not in a function library), QTP does not recognize the methodregistration because it occurred earlier to the beginning of the current runsession and this all is due to the reason that QTP clears all methodregistrations at the beginning of each run session.
If you want to use Option Explicit statement in Function Library, you must include it in all the function libraries associated with the test otherwise QuickTest ignores all the Option Explicit statements in all function libraries.
Steps using user-defined functions are not displayed in the test results tree of the Test Results window by default. For function to appear in the test results tree, you must add a Reporter.ReportEvent statement to the function code
If a function library that is referenced by a test is modified by you or any other user using an external editor, the changes will take effect only after the test is reopened.
Always make sure that each function has a unique name, if more than one function with the same name exists in the test script or function library, QTP will always call the last function because QuickTest searches the test script for the function prior to searching the function libraries.
Most important of all: If you register a method within a reusable action, it is strongly recommended to unregister the method at the end of the action (and then re-register it at the beginning of the next action if necessary), so that tests calling your action will not be affected by the method registration.
We can re-register the same method with different user-defined functions without first unregistering the method. When it is unregistered it is reset to its original QTP functionality e.g.
RegisterUserFunc "WebEdit", "Set", "MySet"
RegisterUserFunc "WebEdit", "Set", "MySet2"
UnRegisterUserFunc "WebEdit", "Set"
After running the UnRegisterUserFunc statement, the Set method stops using the functionality defined in the MySet2 function, and returns to the original QuickTest Set functionality, and not to the functionality defined in the MySet function.
If there are two associated function libraries that define the same variable in the global scope using a Dim statement or define two constants with the same name, the second definition causes a syntax error. Include a Dim statement only in the last function library (since function libraries are loaded in the reverse order), . If you need to use more than one variable with the same name in the global scope.



4 comments:

Dmitry Motevich said...
This comment has been removed by a blog administrator.
Anonymous said...

Hey There. I discovered your weblog the use of msn.
That is an extremely well written article. I will be sure to bookmark it and return to read
more of your useful information. Thanks for the post. I will
certainly return.

Feel free to surf to my blog: sedot wc denpasar

Anonymous said...

Hi there, You've done an incredible job. I will certainly digg it and personally recommend to my friends. I am confident they will be benefited from this website.

Here is my homepage rinoplasti

Anonymous said...

Hi there! I know this is kinda off topic but
I was wondering which blog platform are you using for this
website? I'm getting tired of Wordpress because I've had
problems with hackers and I'm looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.

Here is my blog ... watch online movies