Page 1 of 1

Getting all child tree items at run time

Posted: Thu Jan 17, 2019 7:38 pm
by rickcuddihey
Hi,

I have a parent tree element that can have different child elements at run time. I don't care about the child elements I just want to expand all of them because they also have children. I cannot put all the child elements in the repo because there are many and as I mentioned they can be different so I don't know what they will be in terms of text, etc.

I do have the parent element in the repo because it does not change. How can I get the run time element using the repo item for the parent node?
Once I get this I can easily get the child elements under the parent.

Right now I have this, yes I know it not much but I've been messing around for awhile trying to figure it out and reset :)

public void Set_value_TreeItem(RepoItemInfo treeitemInfo)
{
var toptreeitem = treeitemInfo.FindAdapter<TreeItem>();


Note I am an Automation developer with 12 years experience in Automation and 5 years in software development so I don't need much explanation I just need to know how to access the run time application objects like Test Complete and other tools do instead of using the repository items.

Thank you !!!

Re: Getting all child tree items at run time

Posted: Thu Jan 17, 2019 8:54 pm
by odklizec
Hi,

I think this example code should help you...
https://www.ranorex.com/help/latest/han ... oryelement

Just instead of button, user treeitem element and do whatever you want with individual tree items.

Re: Getting all child tree items at run time

Posted: Fri Jan 18, 2019 9:11 pm
by rickcuddihey
Great. Thank you. That did help. I can expand the three children under the top node. After that I cannot get the children of the next nodes.

This truly is frustrating. I must need to invoke an update on each child after I get the list from CreateAdapter() or something???

Here's where I am. If you any suggestions I would appreciate it.

public void Set_value_EngineTreeItem(RepoItemInfo treeitemInfo)
{
var parent = treeitemInfo.CreateAdapters<Ranorex.TreeItem>();

foreach (Ranorex.TreeItem child in parent)
{
// works and expands the child
child.Expand();

// does nothing, no items
foreach (Ranorex.TreeItem anotherchild in child.Items)
{
anotherchild.Expand();
}

// does not return anything so foreach does nothing
var nextchildern = child.FindChildren<TreeItem>();

foreach (Ranorex.TreeItem anotherchild in nextchildern)
{
anotherchild.Expand();
}
}
}

Re: Getting all child tree items at run time

Posted: Mon Jan 21, 2019 12:03 pm
by McTurtle
Hi Rick,

I think that we will need a Ranorex Snapshot in order to help you. Please expand all the whole tree manually and then create a Ranorex Snapshot of the root element. Please create a snapshot like this: How to create a Ranorex Snapshot

Regards,
McTurtle

Re: Getting all child tree items at run time

Posted: Wed Feb 12, 2020 11:12 pm
by viorel.mirea
Hi,
Have you found a soulution? I am trying to do something similar.

Re: Getting all child tree items at run time

Posted: Thu Feb 13, 2020 11:49 am
by odklizec
Hi viorel.mirea,

Without knowing more details about your specific issue and without seeing, at very least, a Ranorex snapshot (not screenshot) of the list of items you want to process, there is not much anyone here can do or suggest. Please create a new topic and post all relevant details about the problem you are trying solve. Thanks.

Re: Getting all child tree items at run time

Posted: Fri Nov 13, 2020 2:56 pm
by mrt
sound like a plan, thank you.

For maintainability I want to pass the chips item itself to the usercode where the validation takes place.

What is the best (shortest) command for getting this one child in user code?
Getting the whole list and then filtering seems unnecessary to me, do you know a quick hint?

thanks buddy

Re: Getting all child tree items at run time

Posted: Fri Nov 13, 2020 3:02 pm
by odklizec
Hi,

I guess you posted the last comment in wrong post? ;)

Re: Getting all child tree items at run time

Posted: Fri Nov 13, 2020 3:11 pm
by mrt
right :D