【发布时间】:2024-05-18 17:05:02
【问题描述】:
我们继承了一个大型的旧版 WinForms 应用程序,即使用 DevExpress 控件 (DevExpress.XtraNavBar.v8.1 和 DevExpress.XtraEditors.v8.1)(我已经能够升级到版本15.1. DevExpress提供的Project Converter工具,可以让你使用最新的DevEpress控件。
停止手动测试并创建自动化套件来测试应用程序的压力很大。我们已经调查了那里的工具,White framework 是满足我们需求的最佳工具。
问题在于 DevExpress 控件,因为我们根本无法识别它们。尽管我们能够识别这些控件的父级。
var application = Application.Launch(@"C:\App\app.exe");
var window = application.GetWindow(SearchCriteria.ByAutomationId("MainMDI"), InitializeOption.NoCache);
var menu = window.Get(SearchCriteria.ByAutomationId("navBarMainMenu")); // this is the parent of those DevExpress controls
// here throws an exeception because cannot find the 'Users' menu item (it is actually other text)
var users = menu.Get(SearchCriteria.ByText("Users"));
users.Click();
在“inspect.exe”中显示父母有孩子:
更新:
我尝试了获取父母的孩子,但它返回了一个包含零项的列表:
var application = Application.Launch(@"C:\App\app.exe");
var window = application.GetWindow(SearchCriteria.ByAutomationId("MainMDI"), InitializeOption.NoCache);
var menu = window.Get(SearchCriteria.ByAutomationId("navBarMainMenu"));
System.Windows.Automation.AutomationElement automationElement = menu.AutomationElement;
AutomationElementCollection automationElementCollection = automationElement.CachedChildren; // the collection is empty
foreach (AutomationElement element in automationElementCollection)
{
string name = element.Current.Name;
if (name == "Users")
{
// try to click on it
}
}
更新 2:
我已将 DevExpress 升级到 v15.2,但我仍然找不到任何自动化 ID。
P.S:抱歉,绿色矩形,客户端不想显示应用程序中的任何内容。
【问题讨论】:
标签: c# winforms devexpress-windows-ui white-framework