I have a set of div's all class are same we are not using any tables. but I can find the the child item I am looking for and I need to find everything associated with that child. My idea was to go up the parentNode and fine the parent div where everything located for the item. I can get the class name for the parent.
Set dscBOGO = Description.Create()
dscBOGO("Class").Value = "bogoBadge"
dscBOGO("micClass").Value = "WebElement"
Set objBOGO = Browser("Page").Page("Page").ChildObjects(dscBOGO)
this will give me a class name. but what would be the best way to loop through so I can find the exact parent instead of adding parent like above? above fails if they add another node as a parent.
If I can find the parent then i can find all all others. [img]/images/graemlins/smile.gif[/img]
I came up with similar solution. here is my code as well incase someone need it later. I had to go backword because I have like 40 list of items which is not in a table and looking for a one item which and everything associated with it. so it is easy to do backword than finding from top.
In here you can find any parent based on your property. [img]/images/graemlins/smile.gif[/img]
<font class="small">Code:</font><hr /><pre>
Set objParent = fFindParentObject(objBOGO.Item(0),"className","pho neItem")
Function fFindParentObject(ByRef objObject, ByVal strType, ByVal strTypeValue)
Dim strParentNode, strNewParent, strNodeType
Set objNewNode = objObject.Object 'Set the objects for item.
'bolFound = False 'Set the ob
strNewParent = strNewParent & ".ParentNode"
strParentNode = "objNewNode" & strNewParent
strNodeType = strParentNode & "." & strType
If StrComp(Eval(strNodeType), strTypeValue,1) = 0 Then
Set fFindParentObject = Eval(strParentNode)
Loop Until Eval(strParentNode).NodeName= "HTML"
If Not IsObject(fFindParentObject) Then Set fFindParentObject = Nothing 'set he function to nothing.
Set objNew = Nothing 'Release object from Memory
Ganesh: I included 'HTML' there because that is the parent-most node, and that's where the code must exit out instead of throwing an error. It could be any other parent element including TD, TR, TABLE, BODY etc.