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

Coded UI GridView Button event not firing

0 Answers 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 04 Sep 2013, 11:21 AM

We are unable to automate testing for our WPF application using MS Coded UI test. The sample application contains a RadGridView with just two columns. In one column, we have added a button which displays a Message Box on click. We are trying to automate this button click.

The grid is defined like this:

<telerik:RadGridView x:Name="MyLinkGrid" Height="135" AutoGenerateColumns="False" Margin="10" Width="300">

    <telerik:RadGridView.Columns>

        <telerik:GridViewDataColumn x:Name="GridViewDataColumnID" Header="ID" DataMemberBinding="{Binding Name}" />

        <telerik:GridViewColumn x:Name="GridViewDataColumnName" Header="Name" IsReadOnly="True">

            <telerik:GridViewColumn.CellStyle>

                <Style TargetType="telerik:GridViewCell">

                    <Setter Property="Template">

                        <Setter.Value>

                            <ControlTemplate>

<Button x:Name="colID" Content="{Binding ID}" VerticalContentAlignment="Center" Foreground="Blue" Click="Button_Click" Width="Auto" AutomationProperties.AutomationId="{Binding ID}" />

                            </ControlTemplate>

                        </Setter.Value>

                    </Setter>

                </Style>

            </telerik:GridViewColumn.CellStyle>

        </telerik:GridViewColumn>

    </telerik:RadGridView.Columns>

</telerik:RadGridView>

private void Button_Click(object sender, RoutedEventArgs e)

{

    MessageBox.Show("Button_Click");

}

During playback the button click event is not automated.

However if we move the ID column after the Name column, the button click event is played back and message box is displayed.

Attached is the sample WPF app along with the Coded UI test project.

Also if we add DataTemplate to our column definition, the button click event doesn’t occur during playback. 

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Tim
Top achievements
Rank 1
Share this question
or