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

UI automation

4 Answers 306 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
MrSm1th
Top achievements
Rank 1
MrSm1th asked on 28 Apr 2011, 01:16 AM
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;
}

4 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 28 Apr 2011, 11:50 AM
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
0
MrSm1th
Top achievements
Rank 1
answered on 28 Apr 2011, 01:43 PM
Thanks, new version works correctly.
0
Sandeep
Top achievements
Rank 1
answered on 09 Apr 2013, 05:26 AM
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
0
Tina Stancheva
Telerik team
answered on 11 Apr 2013, 01:16 PM
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.

Tags
TabControl
Asked by
MrSm1th
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
MrSm1th
Top achievements
Rank 1
Sandeep
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or