Page 1 of 1

TreeItem looses data

Posted: Mon Mar 29, 2010 11:38 am
by max
After opening the context menu of a treeitem, the treeitem object looses all of its data.
For example:

Code: Select all

TreeItem item = ...
item.Click(MouseButtons.Right);
repo.ContextMenu.MenuItem.Select();
Now the properties of "item" are empty, 0 or false.

As a workaround I can do:

Code: Select all

TreeItem item = ...
RxPath itemPath = item.GetPath();
item.Click(MouseButtons.Right);
repo.ContextMenu.MenuItem.Select();

TreeItem workaroundItem = Host.Local.FindSingle<TreeItem>(itemPath);
"workaroundItem" can then be used as usual.

Re: TreeItem looses data

Posted: Mon Mar 29, 2010 12:53 pm
by Support Team
Hi,

I've tried following code using Ranorex 2.2.2
Ranorex.TreeItem item = "treeItemPath";                
item.Click(MouseButtons.Right);                
Ranorex.MenuItem menuItem = "contextMenuItemPath";
menuItem.Select();
and I don't lose data of tree item after selecting of a menu item. Maybe you override your tree item on another line in code or is the tree item after selecting the menu item not more valid?

Regards,
Peter
Ranorex Support Team

Re: TreeItem looses data

Posted: Mon Mar 29, 2010 1:52 pm
by max
I don't know if item is valid after selecting menu item. How to check this?
I think it has worked in a previous version of Ranorex. But I'm not sure. Maybe it's a change in AUT.
As long as the workaround works, it's no problem for me.

Re: TreeItem looses data

Posted: Mon Mar 29, 2010 5:04 pm
by Support Team
Hi,
max wrote:I don't know if item is valid after selecting menu item. How to check this?
If an element is still valid, its Valid property returns true.

I guess that there is some change in the UI that renders the TreeItem item invalid when the context menu pops up. That's why Ranorex can't get any data from the actual tree item any more. However, once you renew the item by searching for its RxPath, it will work again.
Instead of getting the path from the item you could also get the item from the repository again. This will improve performance, since the Ranorex repository caches folder items.

Regards,
Peter
Ranorex Support Team