Micro Focus QTP (UFT) Forums
Unable to identify immediate parent in hierarchy - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Unable to identify immediate parent in hierarchy (/Thread-Unable-to-identify-immediate-parent-in-hierarchy)



Unable to identify immediate parent in hierarchy - martinshort - 11-18-2013

Hi

I have a form hierarchy as follows:

1. SwfWindow("swftypename:=Hummingbird\.DM\.Extensions\.Forms\.LocationSave\.LocationSaveForm") =>
2. SwfObject("swfname:=profileTypeFormCompositeUserControl") =>
3. SwfObject("swfname:=panelControlProfileScroller") =>
4. SwfObject("swfname:=formInterpreterControl") =>
5. SwfObject("swfname:=DOCNAME") =>
6. SwfObject("swfname:=buttonEditCtl") =>
7. SwfObject("swfname:=SwfEdit") =>

The problem is that the form is so poorly designed, that the field name and the field contents are at two different levels in the hierarchy.

Level 5 contains the field name
Level 7 contains the actual field content.

What I am after is to identify the parent of the parent in the heirarchy. Now I have managed to use a series of nested childobject/FOR...NEXT loops to drill down to the item required, it would be better for my purposes to start at the bottom of the hierarchy and work upwards to the parent.

I've tried various variations on the code below, but the best I could get was the code recognising the parent as top level parent object and not recognising the intermediate objects.

Code:
Set descSwfEdit = Description.Create
descSwfEdit("micClass").Value = "SwfEdit"
Set colSwfEdit = SwfWindow("swftypename:=Hummingbird\.DM\.Extensions\.Forms\.LocationSave\.LocationSaveForm").SwfObject("swfname:=profileTypeFormCompositeUserControl").SwfObject("swfname:=panelControlProfileScroller").SwfObject("swfname:=formInterpreterControl").ChildObjects(descSwfEdit)
For k = 0 To colSwfEdit.Count - 1
    msgbox colSwfEdit.GetROProperty("micClass") & VBCR & colSwfEdit.GetROProperty("text")
Next 'k

Is it possible to tweak this to look at the immediate parent or am I stuck with having to use my long-winded iterative trek downwards through the various levels?

Thanks