For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
An important update from QtpSudhakar. I stopped giving classroom training in MindQ Systems. I have bigger plans and I want to put an end to regular classroom training because very less people are practicing. From now onwards every session of mine is going to have explanation and practice. Everyone should practice in presence of mine and should go out of classroom with practical knowledge. So I started my own institute AnyTechLabs in Madhapur. Please reach out to +91-8328152362 for course details. Visit AnyTechLabs.com for address details.
Selenium + Cucumber 24th October 7.30 AM IST to 9.00 AM IST 45 Days WeekDay Online

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Tuesday, September 15, 2009

Object Hierarchies in QTP

Is it Mandatory to Follow Object Hierarchies Specified by QTP?

We all know that the basic object hierarchy specified by QTP is from parent to child. If is there multiple parent hierarchies then we have to start from higher level parent.


1. Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click 
2. Browser("Browser").Dialog("Internet Security Alert").WinButton("Yes").Click 

But we don't need to follow the basic hierarchy in this case. We can ignore the top level parent object to work with Dialogs.

Using the below code you can directly work with Objects in Dialog.

'Using the Function
Set oObjDescription=CreateObjectDescription("text:=OK")
set oObject=GetDialogObject("Open Order",oObjDescription)


Function GetDialogObject(oDialogTitle,oObjProperties)

Dim oDialog
Dim iIndex
Dim oDialogName
Dim oDialogObjects

Set oDialogDescription=Description.Create

Set oDialogObjects=Desktop.ChildObjects(oDialogDescription)

If  oDialogObjects.count=1 Then

For iIndex=0 to oDialogObjects.count-1
If  trim(lcase(oDialogName))=trim(lcase(oDialogTitle)) Then
Set oDialogChildCollection=oDialogObjects(iIndex).ChildObjects(oObjProperties)
If  oDialogChildCollection.count=1 Then
Set GetDialogObject=oDialogChildCollection(0)
elseIf  oDialogChildCollection.count>1 Then
msgbox "More Objects Found With Provided Properties"
ElseIf  oDialogChildCollection.count=0 Then
msgbox "No Object Found With Provided Properties"
End If
Exit For
End If
ElseIf  oDialogObjects.count>1 Then
msgbox "More Objects Found With Provided Properties"
ElseIf  oDialogObjects.count=0 Then
msgbox "No Object Found With Provided Properties"
End If

Set oDialog = Nothing
Set oDialogObjects = Nothing
Set oDialogChildCollection = Nothing

End Function

Function CreateObjectDescription(StrProperties)

Dim objDescription
Dim ObjArr
Dim PropCount
Dim ObjProperty

Set objDescription=Description.Create


For PropCount=0 to ubound(ObjArr)

Set CreateObjectDescription=objDescription

End Function


For Web Applications we follow the hierarchy like this

Browser("browser").Page("page").WebEdit("edit").Set "Sudhakar Kakunuri"

The same statement will work without page object.


Browser("browser").WebEdit("edit").Set "Sudhakar Kakunuri"

Please send your Suggestions, Doubts about my blog and posts to my yahoo group http://in.groups.yahoo.com/group/qtpsudhakar

No comments :

Post a Comment