Page 1 of 1

Localization Independent Automation of a TreeView

Posted: Wed May 27, 2009 10:33 am
by Hmueh
Hi,
we are creating automated tests targetting a windows forms-application which uses only standard Winforms-Controls of VS2008.
But it will be localized in various languages. Our problem is now to create tests that will be running on different language versions.

To target Controls like e.g. Buttons and textboxes, we can use their Controlname, which is fine.
But: Treeview-Nodes are no controls in VS2008, so they have no Controlname at all.
Ranorex TreeItem-Adapter addresses the nodes directly using the displayed Text - which is no option in our case because it is altered in different languages.

Is there a way to overcome our problem, eventually by effecting and misusing something like the AccessibleDescription (a problem is: we can not change Treenode-AccessibleValues in VS2008)?

best Regards
Hannes Mühlenberg

Posted: Wed May 27, 2009 3:42 pm
by Support Team
We are currently planning to add better support for the .NET tree / listview classes. For now I can offer a workaround, which might be slow if you have many nodes:

Code: Select all

TreeItem someTreeItem = .. some tree item ..
Control treeViewControl = .. your treeview control ...

System.Windows.Forms.TreeNode node = treeViewControl.InvokeMethod(
                                "GetNodeAt",
                                new object[] { someTreeItem.Element.ClientRectangle.Location + new Size(1, 1) })
                                    as System.Windows.Forms.TreeNode;

The downside is that you have to do this for every "candidate" node.

Another way is to use treeViewControl.InvokeRemotely(), walking through the nodes and looking for the right name, and then returning the right TreeNode (which is faster, but needs more code).

For an example of how to use InvokeRemotely() please have a look at:
http://www.ranorex.com/blog/transfering ... et-control

Michael
Ranorex Team

Re: Localization Independent Automation of a TreeView

Posted: Tue Dec 15, 2009 11:29 am
by Haggy
Is there a better solution right now ?

Whats the downside of setting Node.Accessiblity.Name to a fix Value ?

I'm using an Infragistics UltraTree

Re: Localization Independent Automation of a TreeView

Posted: Wed Dec 16, 2009 11:55 am
by Support Team
Ranorex gets the text of .NET treeview items from its Accessible.Name attribute; i.e. the Accessible.Name and the TreeItem.Text attributes of .NET treeview items are the same. Consequently, if you set the Node.Accessibility.Name of the tree item to a fixed value, I guess that Ranorex will always report that fixed value as the TreeItem.Text attribute.

If you need to have a language independent identifier for a tree node, you should better use another property of the Node.Accessibility object, one that you would normally not use, e.g. "Help", "Description", "HelpTopic", or "KeyboardShortcut". I don't know which of these properties you can set on a Infragistics UltraTree node.

Regards,
Alex
Ranorex Support Team