Hello,
I have a big issue: I keep a reference to a Tree object in the repository, searching it dynamically for TreeItem children.
The problem is, the Tree's state is only valid at the moment of retrieving the Tree property from repository (creating the adapter basically).
When the tree changes, these changes are not reflected automatically, only when a new instance of the repository item is created.
This makes it very hard to cope with various scenarios i'm trying to deal with (basically for every change in UI, i will have to create a new adapter to be able to find the element in the tree).
What can i do? is there any way to have the TreeItem automagically update itself somehow?
Tree changes, changes not reflected in code
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Tree changes, changes not reflected in code
This is technology dependent and also dependent on the implementation of the control itself. Usually, an item should only get invalid if its parent structure changes.liortal wrote:The problem is, the Tree's state is only valid at the moment of retrieving the Tree property from repository (creating the adapter basically).
Would kind of technology is the tree made of?
Could you post a Ranorex snapshot?
And could you be a little more specific on the kind of change that needs to occur in the tree to make the corresponding tree items invalid?
If the items are getting invalidated or do not represent the correct structure any more after a change in the tree, the only way to to update the tree item is to search it anew. If you have a repository item corresponding to the tree that can easily be done using the "Info" object corresponding to the tree item and its CreateAdapter method.liortal wrote:What can i do? is there any way to have the TreeItem automagically update itself somehow?
Another way is to use the GetPath method on the tree item, store the returned path, and then search the tree item anew using the stored path in order to update it.
Regards,
Alex
Ranorex Team
Re: Tree changes, changes not reflected in code
This is exactly the (temporary) solution i've used.liortal wrote:Another way is to use the GetPath method on the tree item, store the returned path, and then search the tree item anew using the stored path in order to update it.
I will attach a snapshot to show you which kind of control it is.
Re: Tree changes, changes not reflected in code
Attaching the tree root snapshot.
Scenario i am working on:
1. Tree root is added to repository.
2. Adding new nodes to the tree.
3. After nodes added -> need to locate nodes, click them, and create subnodes for these.
4. Process repeats as long as necessary.
Step #3 is problematic -- the new elements are not found as children to the root node, as retrieved in step #1. The root needs to be updated at each step, and each node needs to be looked-up (very bad performance).
Scenario i am working on:
1. Tree root is added to repository.
2. Adding new nodes to the tree.
3. After nodes added -> need to locate nodes, click them, and create subnodes for these.
4. Process repeats as long as necessary.
Step #3 is problematic -- the new elements are not found as children to the root node, as retrieved in step #1. The root needs to be updated at each step, and each node needs to be looked-up (very bad performance).
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Tree changes, changes not reflected in code
Thank you for posting the snapshot. It looks like this problem is specific to MSAA tree items ("Accessible" adapter), which are usually found in Windows Forms tree views. As I said before, this is not the usual behavior with Ranorex - it looks like a bug.
Consequently, I filed a bug report for this issue and we keep you posted of the outcome of the research, ok? Thank you for bringing this issue to our attention!
Regards,
Alex
Ranorex Team
Consequently, I filed a bug report for this issue and we keep you posted of the outcome of the research, ok? Thank you for bringing this issue to our attention!
Regards,
Alex
Ranorex Team
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Tree changes, changes not reflected in code
We have researched that problem now:
It is indeed specific to some tree items of the MSAA technology ("Accessible" capability/adapter). Natively, for some trees MSAA returns only a flat list of all tree items in the tree instead of a real tree of items. Ranorex converts this flat list to a tree of elements, but it can only do so by storing the items in each level for performance reasons, since updating the children of a tree item would mean getting all(!) items in the tree again.
So we cannot change the implementation to always update the children as explained above, but we will provide an alternative with Ranorex 3.1.0 in terms of the AccessibleTreeItem.UpdateSubTree method. This method instructs Ranorex to update the sub tree below the tree item (will internally get all items in the tree again and re-create the element tree). Consequently, you have to call that method every time before you access the children/descendants of the tree item you got a reference of:
Alex
Ranorex Team
It is indeed specific to some tree items of the MSAA technology ("Accessible" capability/adapter). Natively, for some trees MSAA returns only a flat list of all tree items in the tree instead of a real tree of items. Ranorex converts this flat list to a tree of elements, but it can only do so by storing the items in each level for performance reasons, since updating the children of a tree item would mean getting all(!) items in the tree again.
So we cannot change the implementation to always update the children as explained above, but we will provide an alternative with Ranorex 3.1.0 in terms of the AccessibleTreeItem.UpdateSubTree method. This method instructs Ranorex to update the sub tree below the tree item (will internally get all items in the tree again and re-create the element tree). Consequently, you have to call that method every time before you access the children/descendants of the tree item you got a reference of:
TreeItem treeItem = ...; Ranorex.AccessibleTreeItem msaaTreeItem = new Ranorex.AccessibleTreeItem(treeItem); msaaTreeItem.UpdateSubTree(); // treeItem.Items should now be updatedRegards,
Alex
Ranorex Team