UI automation

5 posts, 1 answers
  1. MrSm1th
    MrSm1th avatar
    2 posts
    Member since:
    Apr 2011

    Posted 27 Apr 2011 Link to this post

    Hi, I'm coding UI tests and the most common task is to navigate to controls situated in different tabs using automation. The problem is I can't get the content of tabs except the tab selected by default. That is, I change between different tab pages and only the first one's automation tree is visible. The code is something like that below. The default WPF tab control works fine: I can get the content of currently selected tab. So how can this problem be solved? Thanks in advance.

    [TestMethod]
    public void TestMethod()
    {
        // find app window
        var cond = new PropertyCondition(AutomationElement.NameProperty, "MainWindow");
        AutomationElement foundWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children, cond);
     
        // find tab control
        cond = new PropertyCondition(AutomationElement.ControlTypeProperty, System.Windows.Automation.ControlType.Tab);
        AutomationElement foundTab = foundWindow.FindFirst(TreeScope.Subtree, cond);
     
        var tabCtl = (WpfTabList)UITestControlFactory.FromNativeElement(foundTab, "UIA");
     
        foreach (var tab in tabCtl.Tabs)
        {
            var elements = "";
            Mouse.Click(tab);
     
            // do something to controls,
            // for example collect their names
            foreach (var el in Walk(tab.NativeElement as AutomationElement))
            {
                elements += string.Format("Name: '{0}', Type: '{1}'\n", el.Current.Name, el.Current.ControlType.ProgrammaticName);
            }
            MessageBox.Show(elements);
        }
    }
     
    // Recursively walk an automation tree
    private List<AutomationElement> Walk(AutomationElement current)
    {
        var res = new List<AutomationElement>();
        if (current != null)
        {
            res.Add(current);
            res.AddRange(Walk(TreeWalker.RawViewWalker.GetFirstChild(current)));
            res.AddRange(Walk(TreeWalker.RawViewWalker.GetNextSibling(current)));
        }
        return res;
    }
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 28 Apr 2011 Link to this post

    Hi MrSm1th,

    This is a known issue in the RadTabControl and the good news is that it is already fixed and the fix is included in the latest internal build of the RadControls Suite for WPF (0419).

    Kind regards,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. MrSm1th
    MrSm1th avatar
    2 posts
    Member since:
    Apr 2011

    Posted 28 Apr 2011 Link to this post

    Thanks, new version works correctly.
  5. Sandeep
    Sandeep avatar
    3 posts
    Member since:
    Mar 2013

    Posted 09 Apr 2013 Link to this post

    Hi,

    I am doing Coded UI test for WPF application having the Rad controls.
    And I am using VSTS 2012 with Q1 2013 rad controls package. I am able to automate all the tab page controls which is opened by default.
    I am able to click on another tab through automation code.. But I am not able to get any controls inside tha tab page.
    Please help me on this.

    Thanks,
    Sandeep
  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 11 Apr 2013 Link to this post

    Hello Sandeep,

    As you said that you can use the RadTabControl AutomationPeers to manipulate the currently selected tab as well as to select another tab, I am not sure if this issue is related to RadTabControl. On our side we can successfully automate the control and its content in a sample solution.

    This is why it would be best if you can create a new support ticket and attach a sample solution demonstrating your issues in it. Then we will be able to take a closer look at your implementation and suggest a solution or a workaround.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready