0
votes

I wanted to manually define a wintree object as described for some other controls in below link https://www.evoketechnologies.com/blog/windows-automation-testing-coded-ui/

First I defined a wintree object in UIMap file as below

    public WinTree WinTreeObject()
    {
    var winTreeProps = new WinTree(WinWindow) { TechnologyName = "MSAA" };
    winTreeProps.SearchProperties.Add("ControlName", "tv");
        winTreeProps.WindowTitles.Add("ProMANAGE ( admin @ Demo )");
    return winTreeProps;
    }

I call like this in the code (it threews exception VS warns if I do not use parantheses for WinTreeObject)

     WinTree uITVTree1 = this.WinTreeObject();

Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnBlockedControlException: Another control is blocking the control. Please make the blocked control visible and retry the action. Additional Details: TechnologyName: 'MSAA' ControlType: 'Tree' ---> System.Runtime.InteropServices.COMException: HRESULT .. 0xF004F003

And here is how it is defined in designer file when I took a record

    public WinTree UITVTree
    {
        get
        {
            if ((this.mUITVTree == null))
            {
                this.mUITVTree = new WinTree(this);
                #region Search Criteria
                this.mUITVTree.WindowTitles.Add("ProMANAGE © ( admin @ Demo )");
                #endregion
            }
            return this.mUITVTree;
        }
    }
1

1 Answers

1
votes

You can always define a Wintree object using Coded UI. One way is as follows:

Private WinTree ProductivityTree
{
    get
       {
           WinTree wintreeObj= new WinTree(parentobj);
           WintreeObj.searchproperties.add(Wintree.PropertyNames.Name,"treeTest");
           return wintreeObj;
         }
}

The error you are getting (i.e. blocked control) comes when there are more controls below the hierarchy and you are trying to access one above.

You can check the hierarchy with the help of test builder.