[Automation] TreeItems WindowsFormsAn application with the target .Net 4.5.2 structure running on WinServer2012 R2 cannot be captured
I created a sample Windows application application containing TreeViewtwo nodes. Each of the two nodes has child nodes. Sort of
-Node0
...Node2
...Node3
-Node1
...Node4
...Node5
...Node6
Using the following code, it seems that the elements of the tree cannot be displayed correctly as a result nodes.Count == 1. I expect Count == 2(Node0 and Node1)
using System.Windows.Automation;
namespace Tester
{
public class Class1
{
public void Test()
{
var desktop = AutomationElement.RootElement;
var forms = desktop.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "MyForm"));
var trees = forms[0].FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "treeView1"));
var nodes = trees[0].FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TreeItem));
}
}
}
Note: I used FindAll()to check if only 1 instance was captured.
Add a link to:
- UIAutomationClient (File version: 4.0.30319.34211, created by: FX452RTMGDR)
- UIAutomationTypes (File version: 4.0.30319.34211) by: FX452RTMGDR)
Some conclusions.
1.
- : Win2008ServerR2
- WinFormsApp:.Net 4.0
- : OK
2.
- : Win2008ServerR2
- WinFormsApp:.Net 4.5.2
- : OK
3.
- : Win2012ServerR2
- WinFormsApp:.Net 4.0
- : OK
4.
- : Win2012ServerR2
- WinFormsApp:.Net 4.5.2
- : - nodes.Count == 1
5.
- : Win2012ServerR2
- WPF:.Net 4.5.2
- : OK
?