【问题标题】:How could I find an application window via it's ClassID?如何通过 ClassID 找到应用程序窗口?
【发布时间】:2011-12-09 19:10:00
【问题描述】:

我正在使用 White 进行自动化测试。我创建了简单的应用程序测试,它通过对话框名称跟踪应用程序。

var appCalc = Application.AttachOrLaunch(new ProcessStartInfo("application.exe"));
var wndCalc = appCalc.GetWindow("Dialog caption");

但这种方法不稳定,因为在不同的本地化中,标题可能会有所不同。我如何使用它的 ClassID 跟踪我的应用程序?

【问题讨论】:

  • 什么是 ClassID?你是说类名吗?
  • 是的,你是对的。我的问题有一个错误。我知道类名
  • 是主窗口吗?应该可以从流程中得出。

标签: c# unit-testing automation automated-tests white-framework


【解决方案1】:
    var wndCalc = appCalc.GetWindow(SearchCriteria.ByNativeProperty(AutomationElement.ClassNameProperty, "Your class name"), InitializeOption.NoCache);

【讨论】:

  • 谢谢。我正在使用从 appCalc.GetWindows() 收到的集合中的搜索。您的解决方案更优化
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-21
  • 1970-01-01
  • 2013-07-18
相关资源
最近更新 更多