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;
}
}