Hi,
Actually the scenario is like this...
There is a tree control which have a parent node and have some childs under it.I need to verify all the child items in the parent node.
I am selecting the parent node through one of my method and then I am trying to verify the childrens under it. For this I wrote the following code but its not working..
public bool VerifyItem(string abc)
{
foreach(TreeItem items in Form.Tree.selectedItems)
{
if(items.decendentItems.text.contains(abc))
{
return true;
}
}
return false;
}
Please help in solving this ASAP
Thanks,
Rakesh
Verify child nodes parent node in Tree
- artur_gadomski
- Posts: 207
- Joined: Mon Jul 19, 2010 6:55 am
- Location: Copenhagen, Denmark
- Contact:
Re: Verify child nodes parent node in Tree
Try replacing selectedItems with Items.
Re: Verify child nodes parent node in Tree
Hi,
I can do that but the thing is that I need to verify the child nodes of specific parent node because there is a chance that the same child nodes can be part of some other parent node but may be they are not present in the parent node which I want to verify
Thanks,
Rakesh
I can do that but the thing is that I need to verify the child nodes of specific parent node because there is a chance that the same child nodes can be part of some other parent node but may be they are not present in the parent node which I want to verify
Thanks,
Rakesh
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Verify child nodes parent node in Tree
Hi!
Do you have tried the two helpfull functions "FindChildren" and "FindDescendants" yet?
They give back a list of all child-nodes and descendant-nodes of type <T>, respectively.
So in your example it will look the following way...
foreach(TreeItem item in tree.FindChildren<TreeItem>())
{
Report.Info("Children",item.Text.ToString());
}
Regards,
Larissa
Ranorex Team
Do you have tried the two helpfull functions "FindChildren" and "FindDescendants" yet?
They give back a list of all child-nodes and descendant-nodes of type <T>, respectively.
So in your example it will look the following way...
foreach(TreeItem item in tree.FindChildren<TreeItem>())
{
Report.Info("Children",item.Text.ToString());
}
Regards,
Larissa
Ranorex Team
Re: Verify child nodes parent node in Tree
Hi,
Yes both FindChildren & FindDecendents are very useful functions but my scenario is completely different.
The tree structure is like shown below
--A
--1
--2
--3
--B
--1
--2
--3
--C
--1
--2
--3
Here A,B,C are parent nodes and each have their childrens as '1,2,3'.
I need to verify all the childrens of parent Node "B".
Please provide me the solution for this ASAP.
Thanks,
Rakesh
Yes both FindChildren & FindDecendents are very useful functions but my scenario is completely different.
The tree structure is like shown below
--A
--1
--2
--3
--B
--1
--2
--3
--C
--1
--2
--3
Here A,B,C are parent nodes and each have their childrens as '1,2,3'.
I need to verify all the childrens of parent Node "B".
Please provide me the solution for this ASAP.
Thanks,
Rakesh
Re: Verify child nodes parent node in Tree
Just root your FindChildren to the XPath of node B...
The last bit of code it rooted at the tree:
foreach(TreeItem item in tree.FindChildren<TreeItem>())
So change the the Tree.FindChildren to NodeBElement.FindChildren...
NOTE: NodeBElement is the element of your node B that you need to determine...
The last bit of code it rooted at the tree:
foreach(TreeItem item in tree.FindChildren<TreeItem>())
So change the the Tree.FindChildren to NodeBElement.FindChildren...
NOTE: NodeBElement is the element of your node B that you need to determine...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...