http://quicktesthp.blogspot.com

QTP VBScript new series + Interview Question Bank on QTP for enrichment of Knowledge in QTP

This Site has been brought to you by HP Certified Expert of QTP.

Exciting new articles for October:

1) QTP Tip:Deselect all Radio Buttons

2) HP QTP Crypt Object

3)Adding Hyperlinks in Excel Spreadsheet

Best of Luck Friends ! ! !

Expert QTP
expert.qtp@gmail.com

All Articles are Copyright Protected. These are Free for Reading & Personal Use. Reproduction in Any Form without the Permission is Illegal & Strictly Prohibited.

Copyright © 2009 ExpertQTP

Google Search

Friday, June 6, 2008

Few Useful Tips on using QTP

Few Useful Tips on Using QTP
Here I am describing few important Tips Under "How To" series. I shall be adding more & more such tips to this repository from time to time.
Here are the "How To" series tips:

1) How to "Turn Off" the results after executing a Script in QTP?
Go to "Tools > Options > Run Tab"
Deselect the option "View results when run session ends".
This will suppress the result window. However a Log shall automatically get created and the same can be viewed any time by manual means.

2) How to add a Page Checkpoint to the Test?
A Page Checkpoint checks the number of images & links in the page during the running of the test & verifies as to whether it is the same as during the recording of the test.

# Identify the page where we wish to add a Page Checkpoint.
# Create Page Checkpoint.
# Do Right-click anywhere over the Active Screen, and choose "Insert Standard Checkpoint". This will open a Object Selection - Checkpoint Properties Dialog Box. Depending upon the place of our click on the Active Screen this Dialog Box shall have different elements,.
# Save the test.

3) How to Suppress the Warnings from the "Test Results Page"?
# While using Test results Viewer Go to "Tools > Filters > Warnings"
# Ensure that the check Box is ‘Unchecked’.

4) How to open a new test using QTP?
If QTP is not currently open:
# Go to Start > Programs > QuickTest Professional > QuickTest Professional.

# Click on ‘Blank Test’ If a Welcome Screen opens. Otherwise, choose File > New, or click the New button. A blank test opens.

If QTP is already open:
# Identify the Web Add-ins already loaded : Go to Help > About QuickTest Professional.
# If the Web Add-in is not loaded; Exit and restart QTP.
# When the Add-in Manager opens, select the desired Web Add-in, and clear all remaining Add-ins.
# Go to File > New, or click the New button. A blank test shall open.

5) How to Save a Test while using QTP?
# Go to File > Save or click the Save button.
# The Save dialog box opens to the Tests Folder.
# Create a new folder where we want to save our test, select it, and then click Open.
# Key in the name of the Test in the File name field. Ensure that Save Active Screen files is selected.
# Click ‘Save’.
The name of the test shall get displayed in the title bar of the main QTP window.

6) How to Create an Output Value using QTP?
# Start QTP and open the Parameter Test.
# Save the Test as Output.
# Ensure that the Active Screen Option is Enabled.
# Select the Text, which is desired to be used as an Output Value.
# Set the Output Value settings.
# Modify the Table Checkpoint. # Save the Test.

7) How to Handle Dynamic Objects in QTP?
QTP has a unique feature by the name Smart Object Identification or recognition.

QTP identifies a particular object by comparing the properties of its test object and the run time object. QTP may not be able to recognize any dynamic objects whose properties may undergo some changes during the run time. Thus its great option of enabling Smart Identification helps us in identifying the objects even if their properties have undergone changes during the run time.

If QTP is not able to detect any object having description matching with that of the recorded object, or in case it detects more than one object having matching description, then QTP ignores the recorded description, and uses the Smart Identification feature to identify the object. Smart Identification mechanism is a bit complex, but flexible. However, if configured logically, Smart Identification definition can help QTP in detecting an object, of course - if present, in-spite of failure of the recorded description.

Smart Identification Feature of QTP uses two types of properties:

a) Base filter properties: Are the most fundamental properties of a particular test object class. Her we can not change their values without changing the essence of the original object.

b) Optional filter properties: Are other properties which help us in identifying the objects of a particular class since these are not likely to get changed frequently. These properties can be ignored in case these are not applicable any more.

8) How to do Scripting by using Built-in functions in QTP?
QTP has a wonderful Built-in feature by the name ‘Step Generator’
Go to Insert->Step->Step Generator - F7, This will generate the desired scripts while we enter the necessary steps.

9) How to Define a Data Table Parameter for QTP?
# Start QTP and open the Checkpoint Test.
# Ensure that the ‘Active Screen’ option is enabled.
# Ensure that the ‘Data Table’ option is enabled.
# Select the Text required to be parameterized.
# Define the Parameterization Properties.

10) How to Covert a String to an integer in QTP?
By using the conversion function : CInt()--->

11) How to open an Application while Scripting in QTP?
SystemUtil, object can be used for opening and closing the applications and processes during a run session.

While recording a test, when we run a particular application from the Start menu or from the Run Dialog Box, SystemUtil.Run statement gets automatically included into the test. Few illustrations are as under

SystemUtil.CloseDescendentProcesses : Closes all Processes opened by QTP
SystemUtil.Run "Notepad.exe"

12) How to terminate a Non Responsive application?
Standard applications can be terminated with the help of running a script in QTP.
SystemUtil.CloseProcessByName "Test1.exe"

Alternatively

SystemUtil.CloseProcessByWndTitle "Define Some Title"

13) How to remove Result Files from Old Tests in QTP?
We can use the ‘Test Results Deletion Tool’ to view a list of all the test results in a specific location in the file system. Subsequently we can delete any of the test results, which are not needed any more.

The ‘Test Results Deletion Tool’ enables us to do the sorting of the test results by name, date, size, and many more characteristics, so that we can shortlist the results desired for deletion.

To find the ‘Test Results Deletion Tool’ go to Start Menu > QuickTest Professional > Tools > Test Results Deletion Tool.

14) How to change the Logical Name of a Test Object in QTP?
During recording an object, QTP uses one of the properties of the object as the logical name for the object. This is the name getting displayed in the ‘Expert View’ and in the ‘Keyword View’.

However we can change the property to something else to be used as the logical name for the object.

e.g. To use the alt property as the logical name of an image, run regedit.exe and set the following key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Image] "tag query name"="alt"

Key Words: QTP, FAQ, Interview Question, Quick Test, Tips, Tips Tricks, smart identification, dynamic object

No comments:

 
Copyright © 2009 ExpertQTP