This is a migrated thread and some comments may be shown as answers.

RadTreeView and Coded UI support (AutomationID property is blank)

9 Answers 198 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 17 Jan 2013, 06:46 PM
We are using the RadTreeView extensively in our product and building the nodes through binding (our application follows the MVVM pattern)? I don't know if that last detail matters but when we handed off an alpha release to our QA department, they are reporting that the AutomationId property is blank when using the Microsoft Coded UI Test Builder. Is this something we need code for or is it something the Telerik control should be providing out of the box? 

9 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 18 Jan 2013, 09:19 AM
Hi Joe,

By default the RadTreeView's and RadTreeViewItem's AutomationId properties are blank and if you want to use it you should set AutomationProperties.AutomationId in your code (in your case in your ViewModel).

Kind regards,
Stefan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Joe
Top achievements
Rank 1
answered on 18 Jan 2013, 01:43 PM
Awesome. Thank you for the clarification.
0
Anchal
Top achievements
Rank 1
answered on 21 Feb 2014, 02:57 PM
Is there any other way apart from adding the ID of the control so that coded UI works properly.
0
Stefan
Telerik team
answered on 25 Feb 2014, 11:31 AM
Hi Anchal,

Unfortunately I am not sure what you mean by "coded UI works properly". Could you please describe your scenario in more details. Basically setting the AutomationProperties.AutomationId allows you to provide IDs for your elements and then access them by those IDs in Coded UI tests. 

If this approach doesn't work for you it would help us if you elaborate on your scenario more in order to further assist you. Also if you can send us a sample project, we will gladly examine it on our side.

Regards,
Stefan
Telerik
0
Anchal
Top achievements
Rank 1
answered on 25 Feb 2014, 02:45 PM
Hi Stefan,

I am using Coded UI VS 2012 for doing automation. Recently developer used added Telerik controls in the application. Coded UI Test Builder is able to spy all the controls apart from Telerik TreeView as Id for TreeView is blank.
So my question is apart from setting the Id of the control in code, is there any way we can do it?
0
Stefan
Telerik team
answered on 26 Feb 2014, 01:55 PM
Hi Anchal,

The only way to set IDs of RadTreeView and then use those IDs in your Coded UI test is setting the control's AutomationProperties.AutomationId property. It can be set in XAML, in code behind and via binding to your ViewModel.

Regards,
Stefan
Telerik
0
Shivani
Top achievements
Rank 1
answered on 03 Mar 2014, 03:08 PM
If we don't have an id for the control how can we perform a coded ui test  automation for that control since we require a automation id for testing through coded ui. 
0
Stefan
Telerik team
answered on 04 Mar 2014, 04:05 PM
Hi Shivani,

Although the AutomationProperties.AutomationId is empty by default, you should still be able to create Coded UI tests for RadTreeView.

Basically the AutomationProperties.AutomationId is used to differentiate a UI Automation element from its siblings. However this property is not mandatory and if it is not set the search criteria in the Coded UI test may use other control's properties like name, class name, help text, etc. In case you need one more search criteria, which to identify better the element you want to verify you can set the AutomationProperties.AutomationId property in XAML, code behind or via binding to your ViewModel.

Regards,
Stefan
Telerik
0
Claudio
Top achievements
Rank 1
answered on 25 Jun 2014, 01:57 PM
If the class or objects of the items you add to the RadTreeView implement the ToString() method, the RadTreeViewItems Name property is automatically set to the return value of the ToString() implementation, so that you can use the Name property for identifying your items in your tree

class Address
 {
     ...
    public override string ToString()
    {
        return this.Name;
    }
}
...
RadTreeViewItem x1 = new RadTreeViewItem();
x1.Header = "x1";
x1.Items.Add(new Address("huhu", "123"));
x1.Items.Add(new Address("haha", "123"));
myTree.Items.Add(x1);
Tags
TreeView
Asked by
Joe
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Joe
Top achievements
Rank 1
Anchal
Top achievements
Rank 1
Shivani
Top achievements
Rank 1
Claudio
Top achievements
Rank 1
Share this question
or