TreeItem looses data

Bug reports.
max
Posts: 8
Joined: Mon Oct 12, 2009 3:43 pm

TreeItem looses data

Post by max » Mon Mar 29, 2010 11:38 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TreeItem looses data

Post by Support Team » Mon Mar 29, 2010 12:53 pm

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

max
Posts: 8
Joined: Mon Oct 12, 2009 3:43 pm

Re: TreeItem looses data

Post by max » Mon Mar 29, 2010 1:52 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TreeItem looses data

Post by Support Team » Mon Mar 29, 2010 5:04 pm

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