Tree changes, changes not reflected in code

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
liortal
Posts: 9
Joined: Sun Jun 19, 2011 8:55 pm

Tree changes, changes not reflected in code

Post by liortal » Thu Jul 07, 2011 11:11 am

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?

User avatar
Support Team
Site Admin
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

Post by Support Team » Fri Jul 08, 2011 2:39 pm

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).
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.

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?
liortal wrote:What can i do? is there any way to have the TreeItem automagically update itself somehow?
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.
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

liortal
Posts: 9
Joined: Sun Jun 19, 2011 8:55 pm

Re: Tree changes, changes not reflected in code

Post by liortal » Sun Jul 10, 2011 8:57 am

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.
This is exactly the (temporary) solution i've used.

I will attach a snapshot to show you which kind of control it is.

liortal
Posts: 9
Joined: Sun Jun 19, 2011 8:55 pm

Re: Tree changes, changes not reflected in code

Post by liortal » Sun Jul 10, 2011 12:05 pm

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).
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
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

Post by Support Team » Mon Jul 11, 2011 6:43 pm

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

User avatar
Support Team
Site Admin
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

Post by Support Team » Thu Jul 21, 2011 1:27 pm

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:
TreeItem treeItem = ...;
Ranorex.AccessibleTreeItem msaaTreeItem = new Ranorex.AccessibleTreeItem(treeItem);
msaaTreeItem.UpdateSubTree();
// treeItem.Items should now be updated
Regards,
Alex
Ranorex Team