[Automation] TreeItems of WindowsApplication with target framework .Net 4.5.2 running on WinServer2012 R2 cannot be captured
I've created a sample windows application project containing a TreeView with two nodes. Each of the two nodes has child nodes.
Something like
-Node0
...Node2
...Node3
-Node1
...Node4
...Node5
...Node6
using the following code, it seems the tree items cannot be captured properly resulting to nodes.Count == 1. I'm expecting 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'v been using FindAll to recheck if only 1 instance is being captured.
Add Reference to:
- UIAutomationClient (File Version: 4.0.30319.34211 built by: FX452RTMGDR)
- UIAutomationTypes (File Version: 4.0.30319.34211 built by: FX452RTMGDR)
Some deductions.
- Server OS: Win2008ServerR2
- WinApp Target Framework: .Net 4.0
- Result: OK
- Server OS: Win2008ServerR2
- WinApp Target Framework: .Net 4.5.2
- Result: OK
- Server OS: Win2012ServerR2
- WinApp Target Framework: .Net 4.0
- Result: OK
- Server OS: Win2012ServerR2
- WinApp Target Framework: .Net 4.5.2
- Result: Not OK
Thanks