Advanced QTP - DP and Child Objects - Simple Code To Validate All Links of a webpage

‘SCENARIO NAME :Check all links
‘DESCRIPTION :This code Check all links in any web page
‘PRECONDITIONS :This Assume that when click on Link the new page will open on current window but not in new window
‘AUTHOR :Mohan kumar

Set oDesc = Description.Create()
‘ Retrieve HTML tag
oDesc(”html tag”).Value = “A”
Set rc = Browser(”title:=.*”).Page(”title:=.*”).ChildObjects(oDesc)
num = rc.Count() ’get the number of link in a page
For i=0 to num-1
Set rc = Browser(”title:=.*”).Page(”title:=.*”).ChildObjects(oDesc)
ref = rc(i).GetROProperty(”href”) ’get the “href”propety of the i th link
Browser(”title:=.*”).Page(”title:=.*”).link(”text:=.*”,”index:=”&i).click ’click on i th link
title1=Browser(”title:=.*”).getRoproperty(”title”) ’get the tile of the target page
MsgBox title1
Browser(”title:=.*”).navigate(ref)’Navigates to the url taken from “href” property
title2=Browser(”title:=.*”).getRoproperty(”title”)’get the tile of the tNavigated page
MsgBox title2
If title1=title2 Then’condition to check for the targetted page and Navigated page
Reporter.ReportEvent 0, “Navigated To Correct Page”,”"&title1′Reports if correct
Reporter.ReportEvent 1,”"&title1,”"&title2
End If
Browser(”title:=.*”).back’Navigates back to main page


Source-  -

Count the number of links & Objects in a web page by ChildObjects Method

To count the number of links in a web page, We can use ChildObjects to get the link collection, then retrieve the properties for example number of links or any other objects on page.


Dim oDesc, oAllLinks, iNumberOfLinks
set oDesc = Description.Create()
oDesc("micclass").Value = "Link"
Set oAllLinks = Browser("creationtime:=0").
iNumberOfLinks = aAllLinks.Count
msgbox iNumberOfLinks

Use Local or Shared Object Repositories in QTP? How to Decide?

Deciding Whether to Use Local or Shared Object Repositories in QTP

To choose where to save objects, you need to understand the differences between local and shared object repositories.

QTP Interview Questions and Answers – Part 5

[Source of answers: HP QTP User Guide]
41. How can we run standard DOS commands in QTP tests?
You can run standard DOS commands in your QTP test or function using the VBScript Windows Scripting Host Shell object (
For example, you can open a DOS command window, change the path to C:\, and run the DIR command using the following statements:
Dim oShell
Set oShell = CreateObject ("") "cmd /K CD C:\ & Dir"
Set oShell = Nothing
For more information, refer to the Microsoft VBScript Language Reference (choose Help > QTP Professional Help > VBScript Reference > VBScript).

QTP Interview Questions and Answers – Part 4

How can we define a time interval for QTP to perform a checkpoint successfully?
You can specify the time interval during which QTP attempts to perform the checkpoint successfully by modifying the selections in the bottom part of the Text/Text Area Checkpoint Properties dialog box. You can also specify when to perform the checkpoint.

• Checkpoint timeout. Specifies the time interval (in seconds) during which QTP attempts to perform the checkpoint successfully. QTP continues to perform the checkpoint until it passes or until the timeout occurs. If the checkpoint does not pass before the timeout occurs, the checkpoint fails.

QTP Interview Questions & Answers - Part - 3

How can we do the Analysis of Results in QTP?
The Test Results window contains a graphic and text summary of the results of a run as well as details of each step in the run.

To view the results of a run:
1. If the Test Results window is not already open, click the Results button or choose Automation (menu) > Results.
Tip: You can open the Test Results window as a standalone application from the Start menu. To open the Test Results window, choose Start > Programs > QTP Professional > Test Results Viewer.

1. If there are test results for the current test, they are displayed in the Test Results window.
2. If there are several test results for the current test, or if there are no test results for the current test, the Open Test Results dialog box opens. You can select the test results for any test, or you can search for the test results (results.xml) file anywhere in the file system. Click Open to display the selected results in the Test Results window.
Note: Results files for QTP Professional are saved with a .qtp file extension.
The following example shows the results of a test with three iterations:

(Click on the above image to see the large view)

Problems in maintaining automated QTP test scripts

New versions of software imply a need for new tests for the new functionality, and often changes to existing tests here existing functionality has changed. Furthermore, as the system changes some tests will become redundant, either because the functionality they test has been removed or because new tests have superseded their purpose. All of this contributes to the maintenance costs.

QTP Interview Questions and Answers - Part 2

Which scripting language used by QTP?
Most of the newbie are confuse about this. In many place you will find that QTP uses VBscript, java script and other scripting language.

Actually QTP is using only one language VB script. But it also provide access to its functions and properties thorough it object. That means you can use any other scripting language to access the QTP, but then you will not get the any benefit of its recording technique and other facilities provided by tool.

QTP Interview Questions and Answers - Part 1

What are the Features & Benefits of Quick Test Pro(QTP)..?
1. Key word driven testing
2. Suitable for both client server and web based application
3. Vb script as the script language
4. Better error handling mechanism
5. Excellent data driven testing features