Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with getting the number of children
#1
Not Solved
Hi there,

I have a chunck of codes that counting the children of a webtable
Here is my code:

Code:
Dim obj_ChkDesc
Set obj_ChkDesc = Description.Create()
obj_ChkDesc("class").Value = "datatab_metadata_node"
obj_ChkDesc("innertext").Value = "Accounts"

Dim dataPane
Set dataPane= Browser("title:=InfoView").Page("title:=InfoView").Frame("title:=Multi-Dimensional Designer").WebTable( "innertext:=AccountsYearMarketProductScenario")
Dim allNodes
Set allNodes= dataPane.ChildObjects(obj_ChkDesc)
Dim num
num =allNodes.Count()
MsgBox( num)

The MsgBox show me the num is "0" However, I do expect the num to be "1"

Does any one know what is going on here?

Many thanks

Carol
Reply
#2
Not Solved
Hi Carol,
The code that you have used is right for retrieving the child objects of the web table.The issue that i suppose is in the properties of the object "obj_ChkDesc" that you gave.Also,in place of "class" it should be "Class Name" in 3rd line.Your code is not able to find the child objects having the properties that you defined.So,there is problem in defining the properties of the child object.

-Deepak.
Reply
#3
Not Solved
Hi Deepak,
Thank you so much for your reply. However, still have issue wth this childObjects. Basically , my goal is to find Div within a div. To locate the Div I want to locat, there are multiple layer between. To give you a simply example, it wil be something like :
Browser->frame -> table -> Div ->Table -> Div ->Div
It is the final Div I want to located. However, to make the story compliated, the structure of the final Div isas such :
Code:
<div id="designerForm:mde1_Accounts_member_node" class="datatab_node_div">
    <span id="designerForm:mde1_Accounts_member_minus" >
        <img class="metadata_tree_node_img" src="/../minus_xp.gif"/>
    </span>
    <span clickaction="select">
        <img class="metadata_tree_node_img" src="/../measure_parent_member.gif"/>
    </span>
</div>

I have try to insert this code
Code:
obj_ChkDesc("Class Name").Value = "WebElement"
I got an General Run Error at executed :
Set allNodes= dataPane.ChildObjects(obj_ChkDes
c)

Now my code is as :
Code:
Dim obj_ChkDesc
Set obj_ChkDesc = Description.Create()

obj_ChkDesc("class").Value = "datatab_node_div"
obj_ChkDesc("html tag").value = "div"


Dim dataPane

Set dataPane= Browser("title:=InfoView").Page("title:=InfoView").Frame("title:=Multi-Dimensional Designer").WebElement("class:=datatab_metadata_div").webElement("html id:=designerForm:mde1_tree")

Dim allNodes
Set allNodes= dataPane.ChildObjects(obj_ChkDesc)
Dim num
num =allNodes.Count()

Msgbox(num)

With this I am getting 0 for my num.

If I change
Set allNodes= dataPane.ChildObjects()
I am getting 10. seems like ChildObjects is getting the leave element, In other words, it is counting at the number of SPAN (Notice that inside my DIV , I have SPAN). This is not what I want. I want the Parent Div. Can you suggest a way to get the DIV. also, to add on it, do I need to list out the exact path of the DIV. ( this can be very long). Will I be able to use descript to tell the characters of the elements want, and using a general path such as: browser(1).page(1).frame(1)?

Again, Many thanks to your suggestion.

Carol
Reply
#4
Not Solved
ok...simple things first...what does object spy gives you on spying the particular object?
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#5
Not Solved
Hi Ankur,
The object that I spying on has the following property if considered as a Test Object:
className: WebElement
class: datatab_node_div
html id: designerForm:mde1_@Accounts_hierarchy_node
html tag: DIV
innertext: Accounts
outertext: Accounts
if considered as a Run-time object:
className: datatab_node_div
id: designerForm:mde1_@Accounts_hierarchy_node
tagName: DIV

For this partcular chunk of code, I need to fnd a collection of object that has class:=datatab_node_div, and html tag := DIV ( this will be the group of collection characters). I don't want to include any attributes contain" Accounts" as this is the caption's of the object and can be changed as my data changed.

Here I also attach a screen shot as what is show at shown inside object spy.

Thank you for any insight.

Carol


Attached Files Image(s)
   
Reply
#6
Not Solved
While selecting the properties of the child object incude classname along with class and html tag.It might help.Otherwise you have to assign run time properties of the object to it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Random Number generator and verification problem jinnah 4 10,486 09-28-2012, 04:03 AM
Last Post: jinnah
  Count the number of 3 number appers between 0-3333 SaranKumarV 1 3,884 09-20-2010, 06:32 PM
Last Post: rdemers25

Forum Jump:


Users browsing this thread: 5 Guest(s)