Saturday, February 28, 2009

Set a Custom Directroy for QTP tests

Do you use a different directory than C:\Program Files\HP\Quicktest Professional\Tests to store your tests? If you, you must be sick and tired of manually correcting the save / open path each and every time you start QTP.

This QTP will show you how to change QTP’s default test directory, thus freeing you from endlessly browsing for the relevant directory whenever you save / open a test.

Open the registry editor, and locate the key:
HKCU\Software\Mercury Interactive\Quicktest Professional\MicTest

Or, if you’re working on Windows 64Bit (Credit goes to Tim Payne)HKLM\Software\Wow6432Node\Mercury Interactive\QuickTest Professional\MicTest
There, locate the string value TestsDirectory - it should be set to "C:\Program Files \ HP \ QuickTest Professional\Tests". Doubleclick it to open it, and change to value to the desired directory. Save, close the registry editor, and restart QTP.

Now, whenever you save a test, or initiate the open file dialog, it would start at your desired directory, and not QTP’s default one.

source : http://www.advancedqtp.com/knowledge-base/articles/set-a-custom-directory-for-qtp-tests/

parameterizing an Action

If you look at the Data Table at the bottom of the QuickTest window in the ActionB test, you will see four tabs: Global, Copy of FlightOrder,Sign_in [ActionA], and ReturnHome [ActionA].

Note: If the Data Table is not displayed, choose View > Data Table to display it. The Global tab is a data sheet whose data is used for the entire test. If five rows of data are displayed in the Global table, the test will run five times. In addition, you can create data sets for each action, using the relevant actionsheet. If you parameterize a step using an action parameter and enter five rows of data in the corresponding sheet, then that action will run five times within each test iteration.

Note: The Sign_in [ActionA] and ReturnHome [ActionA] data sheets are displayed in gray and cannot be edited because each of these data sheets belong to the corresponding called action and can be edited from only the called action’s original test.


Next, you will create a data set for the FlightOrder action to check how the application handles multiple orders during a single user session.

1 Open the ActionB test.
If the ActionB test is not already open, choose File > Open and browse to
ActionB. Click Open.
2 Select a step to parameterize.
Expand (+) Copy of FlightOrder > Welcome: Mercury Tours > Find a Flight:
Mercury.
In the toPort row in the Keyword View, click in the Value cell and then click
the parameterization icon . The Value Configuration Options dialog box opens.

Running and Analyzing a Multi-action Test

You will now run the ActionB test. The entire test will run only once, but the
FlightOrder action will run twice; one time for each set of data in the Copy
of FlightOrder data sheet.

1 Run the ActionB test.
Confirm that all Web browsers are closed. Click Run or choose Test > Run. The Run dialog box opens. Select New run results folder and accept the default results folder name. Click OK. When the test run is completed, the Test Results window opens.

2 Examine the test results.
Examine the Results Summary. The test is marked as Done. This indicates that the test ran without any failures (there were no checkpoints to “pass”).

source: referred from QTP User Guide

Monday, February 23, 2009

QTP GetTOProperty, GetROProperty

GetTOPropertiesReturns properties and values which QTP has recorded and will use to identify an object at run time.
GetROPropertyIt will Return the current value (run time value) of the test object property from the object in the application.
GetROProperty retrieves the current property value of the object in the application during the test run.
GetTOPropertyIt will Return the value of a particular property for a test object which QTP recorded to identify an object during Run time. The value is taken from the Object Repository.
GetTOProperty retrieves the values of only those properties that are included in the test object description in Object Repository by QTP.

source: referred from QTP UserGuide

Object Hierarchy in QTP

An interesting point for you to know is (some of you might already be familiar with this)
Even though the object on which you record may be embedded in several levels of objects, the recorded hierarchy does not include these objects. For example, even if the WebButton object on which you record is actually contained in several nested WebTable objects, which are all contained within a Browser and Page, the recorded hierarchy is only Browser > Page > WebButton
For Example (see below image) Object Spy identifies several levels of hierarchy for Submit button, but while recording (or even when using Descriptive Programming) it just uses the below line of code.

source: referred from QTP User Guide

Sunday, February 22, 2009

VBScript in QTP

VBScript (short for Visual Basic Scripting Edition) is a lively Scripting language interpreted via Microsoft's Windows Script Host.
VBScript has many powerful functions and provides excellent support for variables, data types, and error handling.
Two script engines can interpret VBScript- VBScript.dll, which is invoked by asp.dll is used in web environment and Wscript.exe & Cscript.exe in Windows GUI environment using Windows script Host (WSH, We typically use VBScript within WSH to automate systems administration tasks. WSH is the system module that transforms a VBScript file into a Windows executable file). Wscript.exe is used to display output and receive input in Windows GUI format such as dialog and input boxes. Cscript.exe is used in a command-line environment. When VBScript source code is contained in stand-alone files, they have the file extension .vbs. VBScript Variable VBScript Arrays VBScript Functions and Subroutines VBScript Conditional Statements VBScript Looping Statements VBScript Classes