RadTreeView and Coded UI support (AutomationID property is blank)

10 posts, 1 answers
  1. Joe
    Joe avatar
    9 posts
    Member since:
    Mar 2012

    Posted 17 Jan 2013 Link to this post

    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? 
  2. Answer
    Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 18 Jan 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Joe
    Joe avatar
    9 posts
    Member since:
    Mar 2012

    Posted 18 Jan 2013 Link to this post

    Awesome. Thank you for the clarification.
  5. Anchal
    Anchal avatar
    2 posts
    Member since:
    Jan 2014

    Posted 21 Feb 2014 Link to this post

    Is there any other way apart from adding the ID of the control so that coded UI works properly.
  6. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 25 Feb 2014 Link to this post

    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
  7. Anchal
    Anchal avatar
    2 posts
    Member since:
    Jan 2014

    Posted 25 Feb 2014 in reply to Stefan Link to this post

    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?
  8. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 26 Feb 2014 Link to this post

    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
  9. Shivani
    Shivani avatar
    1 posts
    Member since:
    Mar 2014

    Posted 03 Mar 2014 Link to this post

    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. 
  10. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 04 Mar 2014 Link to this post

    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
  11. Claudio
    Claudio avatar
    3 posts
    Member since:
    Jun 2014

    Posted 25 Jun 2014 Link to this post

    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);
Back to Top
UI for WPF is Visual Studio 2017 Ready