Getting all child tree items at run time

Best practices, code snippets for common functionality, examples, and guidelines.
rickcuddihey
Posts: 7
Joined: Fri Mar 14, 2014 8:04 pm

Getting all child tree items at run time

Post by rickcuddihey » Thu Jan 17, 2019 7:38 pm

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 !!!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Getting all child tree items at run time

Post by odklizec » Thu Jan 17, 2019 8:54 pm

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

rickcuddihey
Posts: 7
Joined: Fri Mar 14, 2014 8:04 pm

Re: Getting all child tree items at run time

Post by rickcuddihey » Fri Jan 18, 2019 9:11 pm

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();
}
}
}

McTurtle
Posts: 297
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Getting all child tree items at run time

Post by McTurtle » Mon Jan 21, 2019 12:03 pm

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

viorel.mirea
Posts: 1
Joined: Wed Feb 12, 2020 11:10 pm

Re: Getting all child tree items at run time

Post by viorel.mirea » Wed Feb 12, 2020 11:12 pm

Hi,
Have you found a soulution? I am trying to do something similar.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Getting all child tree items at run time

Post by odklizec » Thu Feb 13, 2020 11:49 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mrt
Posts: 259
Joined: Mon Mar 16, 2020 11:31 am

Re: Getting all child tree items at run time

Post by mrt » Fri Nov 13, 2020 2:56 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Getting all child tree items at run time

Post by odklizec » Fri Nov 13, 2020 3:02 pm

Hi,

I guess you posted the last comment in wrong post? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mrt
Posts: 259
Joined: Mon Mar 16, 2020 11:31 am

Re: Getting all child tree items at run time

Post by mrt » Fri Nov 13, 2020 3:11 pm

right :D