Content inside TabItem's ContentControl were not identified by Coded UI Test

5 posts, 0 answers
  1. Sirisha
    Sirisha avatar
    13 posts
    Member since:
    Jun 2013

    Posted 23 Jan 2014 Link to this post

    Hi Team,
    I have RadTabItem with ContentControl inside it. Coded UI Test is not able to identify the controls placed inside. I am referencing the telerik assemblies from Binaries.NoXaml folder under 4.5 version.

    Can anyone help in resolving it?

    Following is the Xaml template: 
    <telerik:RadTabControl Name="MainTabControl" Visibility="Visible" TabStripPlacement="Left" SelectionChanged="MainTabControl_SelectionChanged">
               <telerik:RadTabItem Header="Define Manual Columns" Visibility="Visible" DataContext="{Binding Customers}">
                   <StackPanel>
                       <ContentControl Content="{Binding}"  Grid.Row="0" Grid.RowSpan="2"  Grid.Column="1"       Width="Auto"  HorizontalAlignment="Stretch"                                     
                                             >
                           <ContentControl.Style>
                               <Style TargetType="ContentControl">
                                   <Style.Triggers>
                                       <DataTrigger Binding="{Binding ReceiveNewsletter}" Value="True">
                                           <Setter Property="ContentTemplate">
                                               <Setter.Value>
                                                   <DataTemplate>
                                                       <StackPanel >
                                                           <TextBlock x:Name="TestPanel1" Text="Test Panel"  Height="50" Width="50" VerticalAlignment="Top"  Foreground="Black" Margin="5"  />
                                                           <TextBlock  x:Name="TestPanel2" Text="Test Panel2" Height="50" Width="50" Foreground="Black" Margin="5"  />
     
                                                           <StackPanel  x:Name="ButtonsStack"   Orientation="Horizontal" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,100,5,0">
     
                                                               <telerik:RadButton x:Name="EditStyle"  ToolTipService.ToolTip="Edit" Height="25" Width="25">
                                                               </telerik:RadButton>
                                                               <telerik:RadButton x:Name="CopyStyle"  ToolTipService.ToolTip="Copy" Height="25" Width="25" >
                                                               </telerik:RadButton>
                                                               <telerik:RadButton x:Name="CancelSave1"  ToolTipService.ToolTip="Delete" Height="25" Width="25" >
     
                                                               </telerik:RadButton>
                                                           </StackPanel>
                                                       </StackPanel>
                                                   </DataTemplate>
                                               </Setter.Value>
                                           </Setter>
                                       </DataTrigger>
     
                                       <!-- EDIT TEMPLATE -->
                                       <DataTrigger Binding="{Binding Temp}" Value="True">
                                           <Setter Property="ContentTemplate">
                                               <Setter.Value>
                                                   <DataTemplate >
                                                       <StackPanel HorizontalAlignment="Stretch" Orientation="Vertical">
                                                        </StackPanel>
                                                   </DataTemplate>
                                               </Setter.Value>
                                           </Setter>
                                       </DataTrigger>
                                   </Style.Triggers>
                               </Style>
                           </ContentControl.Style>
                       </ContentControl>
                   </StackPanel>
               </telerik:RadTabItem>
           </telerik:RadTabControl>


  2. Sirisha
    Sirisha avatar
    13 posts
    Member since:
    Jun 2013

    Posted 27 Jan 2014 in reply to Sirisha Link to this post

    Team,

    Any update on this?

    Regards,
    Sirisha
  3. UI for WPF is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 27 Jan 2014 Link to this post

    Hello Sirisha,

    Thank you for your report. I used your code snippet to reproduce the described issue and I was able to do so only partially - I was not able to get the TextBlocks from the ContentControl's DataTemplate. There were no problems identifying the RadButtons. However there is a way also to identify the TextBlocks and add assertion for them - when you run the TestBuilder and mark (using the Add Assertion option) any of the RadButtons you can navigate to the other controls in the application using the Coded UI Test Builder's navigation button. You can see the described approach in this screen cast.

    I also attached the project I used to test your scenario so that you can examine it.

    Please give this approach a try and let us know if it works for you.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Sirisha
    Sirisha avatar
    13 posts
    Member since:
    Jun 2013

    Posted 27 Jan 2014 in reply to Stefan Link to this post

    Stefan,

    Whatever I have shared is a sample code. But in real time, there would be many buttons and the navigation to reach the edit would be difficult to act on each of the edit box. Isn't it possible to have the TextBlock recognize by the CUIT directly?

    Regards,
    Sirisha

  6. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 29 Jan 2014 Link to this post

    Hi Sirisha,

    The issue you are facing is not caused by the RadTabControl (your scenario also is reproducible with the native TabControl). My investigation shows that the problem is caused by a limitation of the CUIT.

    Unfortunately you are not able to recognize the TextBlocks directly because WPF TextBlocks do not expose themselves to UI automation when they are inside a DataTemplate. I found a few discussions and blog posts focused on the same issue - in these two - link1 and link2, you can find more information about the topic and a possible workaround. Please take a look at these resources and don't hesitate to contact us if you need further assistance. 

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready