Please anyone let us know how to identify the automation id for the control inside the RadGridview cell Template.
Below is the code sample which i tried by giving the automation id but unable to find the id control.
<telerik:GridViewDataColumn Header="######"
IsSortable="True"
IsReadOnly="True"
UniqueName="#######">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ########}"
AutomationProperties.AutomationId="{Binding Path=#######, StringFormat='##########_{0}'}"></TextBlock>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
18 Answers, 1 is accepted
Will it be possible to clarify what your exact scenario is ? Do you want to set custom automation id to an element or probably find the element in a way ?
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

I need to find the automation id inside the element of the cell. I hope, i have answered your question.
Thanks,
Dilip L.
Currently, each element inside the cell will receive a predefined AutomationID that follows the format:
AutomationProperties.SetAutomationId(childElement, string.Format("CellElement_{0}_{1}", this.OwnerCell.ParentDataControl.Items.IndexOf(this.OwnerCell.ParentRow.Item), this.OwnerCell.Column.DisplayIndex));
As for finding and working with the AutomationID, you can find more information in here:
1. Use the AutomationID property
2. Coded UI tests : AutomationId or how to find the chose one (control) !
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Can I not bind AutomationProperties.AutomationId to some property in XAML ?
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" AutomationProperties.AutomationId="{Binding Name}"/>
Because I do not want using default Automation Id (which contains index)
Regards,
Rajendar.
GridViewDataColumn (or any other column) is not a visual element and does not have automation properties. What you can try instead is to work with GridViewCell and set its AutomationId property:
<
Style
TargetType
=
"telerik:GridViewCell"
>
<
Setter
Property
=
"AutomationProperties.AutomationId"
Value
=
"{Binding Value, RelativeSource={RelativeSource Self}}"
/>
</
Style
>
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Thank you for quick responds.
Is anything wrong in my code
-------------------------------------
<Window.Resources>
<Style TargetType="telerik:GridViewRow">
<Setter Property="AutomationProperties.AutomationId" Value="{Binding Value,RelativeSource={RelativeSource Self}}" />
</Style>
</Window.Resources>
<Grid x:Name="LayoutRoot" >
<telerik:RadTreeListView x:Name="radTreeListView"
AutoGenerateColumns="False" ShowColumnHeaders="False" >
<telerik:RadTreeListView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
</telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>
</Grid>
==============
Here name is property.
I am till seeing default automation id only
Regards,
Rajendar.

Thank you for quick responds.
Is anything wrong in my code
-------------------------------------
<Window.Resources>
<Style TargetType="telerik:GridViewRow">
<Setter Property="AutomationProperties.AutomationId" Value="{Binding Name,RelativeSource={RelativeSource Self}}" />
</Style>
</Window.Resources>
<Grid x:Name="LayoutRoot" >
<telerik:RadTreeListView x:Name="radTreeListView"
AutoGenerateColumns="False" ShowColumnHeaders="False" >
<telerik:RadTreeListView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
</telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>
</Grid>
==============
Here name is property.
I am till seeing default automation id only
Regards,
Rajendar.
When you use the binding:
Value="{Binding Name,RelativeSource={RelativeSource Self}}"
That suggests you have property "Name" of each object of type GridViewRow.
I am guessing that you want to bind to a property from your business object that has such "Name" property. If so, you do the following:
<
Style
TargetType
=
"telerik:GridViewRow"
>
<
Setter
Property
=
"AutomationProperties.AutomationId"
Value
=
"{Binding Name}"
/>
</
Style
>
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Thanks for your help.
But that is also not working in my case
--------------------------
<Window.Resources>
<Style TargetType="telerik:GridViewRow" >
<Setter Property="AutomationProperties.AutomationId" Value="{Binding Name}" />
</Style>
</Window.Resources>
<Grid x:Name="LayoutRoot" >
<telerik:RadTreeListView x:Name="radTreeListView"
AutoGenerateColumns="False" ShowColumnHeaders="False" >
<telerik:RadTreeListView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
</telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>
</Grid>
-------------------
Can you please provide any sample application?
Regards,
Rajendar.
I attach a sample project illustrating the behavior and it seems to work correctly. Do you get different behavior on your side ?
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

It is working as expected in RadGridView but not working RadTreeListView.
Why it is not working in RadTreeListView ?
Can you help me to provide unique AutomationId for RadTreeListView Row?
Regards,
Rajendar.
Depending on which control you are working with, you need to target GridViewRow or TreeListViewRow. In case of using RadTreeListView, the setting should be:
<
Style
TargetType
=
"telerik:TreeListViewRow"
>
<
Setter
Property
=
"AutomationProperties.AutomationId"
Value
=
"{Binding Name}"
/>
</
Style
>
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Thank you for your help.
Actually I am using 2014.2.0729.45. It is not working in this version. Even if I replace these dlls in sample application which you have provided , CUIT is showing default Automation Id.
Did you fix this issue in latest version. If yes please tell me from which this fix is available?
Regards,
Rajendar.
Indeed, there used to be an issue that custom AutomationId and Name properties are not respected and I resolved it in one of our internal builds in September. The fix is available from Q3 2014 release.
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Thanks for your information.
I have tested in 2014 Q3. It is working fine with Automation Id but look like there an issue with name property.
Did you fix this issue in latest version. If yes please let me the version?
Regards,
Rajendar.
It turns out the behavior for Name property for TreeListViewRow does not support custom values. I updated that and the fix will be available in our next internal build coming on Monday.
I also updated your Telerik points.
Regards,
Maya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Hi Maya,
I am struggling with the AutomationId in RadGriwView in my project. The guys doing automation testing have troubles because the RadGridView is used in more places and in all instances is the same ID (e.g. CellElement_1_0). They want to have different ID to distinguish. Why the CellElement_1_0 is not prefixed with automation ID that I set for the whole RadGridView element?
I downloaded you example application but still
I can see AutomationId as : CellElement_1_0
There is used following setter and I wonder why it does not work:
<Style TargetType="telerik:GridViewRow" >
<Setter Property="AutomationProperties.AutomationId" Value="{Binding Name}" />
</Style>
The AutomationId of the different elements doesn't get automatically prefixed with its parent AutomationId. Instead, if you want unique Ids for the different gridview cells, you will need to manually set the AutomationId property for them. Then you can apply the unique AutomationId using an implicit style targeting the GridViewCell elements. Similarly, to the code snippet from your last reply.
<
Style
TargetType
=
"telerik:GridViewCell"
>
<
Setter
Property
=
"AutomationProperties.AutomationId"
Value
=
"{Binding MyUniqueCellName}"
/>
</
Style
>
Regards,
Martin Ivanov
Progress Telerik