[自动化] TreeItems无法正确捕获 [英] [Automation] TreeItems Cannot be Captured Properly

查看:62
本文介绍了[自动化] TreeItems无法正确捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[自动化]无法捕获在WinServer2012 R2上运行的目标框架.Net 4.5.2的WindowsApplication的TreeItem

[Automation] TreeItems of WindowsApplication with target framework .Net 4.5.2 running on WinServer2012 R2 cannot be captured

我创建了一个包含TreeView的示例Windows应用程序项目有两个节点。这两个节点中的每一个都有子节点。

类似于什么,如
-Node0

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

...Node2

... Node3

...Node3

-Node1

... Node4

...Node4

.. .Node5

...Node5

... Node6

...Node6

使用下面的代码,似乎树项目不能被正确捕获导致nodes.Count == 1.我期待Count == 2(Node0和Node1)

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:

如果只捕获1个实例,我一直在使用FindAll重新检查。

I'v been using FindAll to recheck if only 1 instance is being captured.

添加参考:


  • UIAutomationClient(文件版本:4.0.30319.34211建立者:FX452RTMGDR)
  • UIAutomationTypes(文件版本:4.0.30319.34211建立者:FX452RTMGDR)

一些扣除额。


  • 服务器操作系统:Win2008ServerR2
  • WinApp目标框架:.Net 4.0
  • 结果:确定
  • Server OS: Win2008ServerR2
  • WinApp Target Framework: .Net 4.0
  • Result: OK


  • 服务器操作系统:Win2008ServerR2
  • WinApp 目标框架:。 Net 4.5.2
  • 结果:确定
  • Server OS: Win2008ServerR2
  • WinApp Target Framework: .Net 4.5.2
  • Result: OK


  • 服务器操作系统:Win2012ServerR2
  • WinApp 目标框架:.Net 4.0
  • 结果:确定
  • Server OS: Win2012ServerR2
  • WinApp Target Framework: .Net 4.0
  • Result: OK


  • 服务器操作系统:Win2012ServerR2
  • WinApp 目标框架:.Net 4.5.2
  • 结果:不行
  • Server OS: Win2012ServerR2
  • WinApp Target Framework: .Net 4.5.2
  • Result: Not OK

谢谢

推荐答案

嗨Back2WorkMinion,

Hi Back2WorkMinion,

这个论坛是关于C#的编程语言,IDE,库,示例和工具,因为您的问题与Visual Studio测试更相关,我们帮助您将其移至Visual Studio 2010和2012论坛中的测试工具以获得更好的支持。

This forum is about the C# programming language, IDE, libraries, samples, and tools, as your issue is more related to the Visual Studio testing, we help you move it to the Test Tools in Visual Studio 2010 and 2012 forum for better support.

感谢您的理解。

最好的问候,

Albert Zhang


这篇关于[自动化] TreeItems无法正确捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆