Localization Independent Automation of a TreeView

Class library usage, coding and language questions.
Hmueh
Posts: 1
Joined: Wed May 27, 2009 9:56 am

Localization Independent Automation of a TreeView

Post by Hmueh » Wed May 27, 2009 10:33 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed May 27, 2009 3:42 pm

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

Haggy
Posts: 2
Joined: Mon Apr 06, 2009 12:03 pm
Contact:

Re: Localization Independent Automation of a TreeView

Post by Haggy » Tue Dec 15, 2009 11:29 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Localization Independent Automation of a TreeView

Post by Support Team » Wed Dec 16, 2009 11:55 am

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