【发布时间】:2017-04-30 10:06:08
【问题描述】:
我正在使用 TestStack White 在 Telerik Winforms 应用程序中自动化测试场景。
应用程序有很多元素,如果我直接搜索一个元素,运行就会过时并且永远不会结束。
所以我进行了手动层次结构搜索以深入了解元素级别以保存性能并使其发挥作用。
然后代码看起来不整洁,因为我大量使用 foreach 自己执行循环。
这是处理性能的正确方法还是我们有更好的方法 使用 TestStack White 时代码简洁又性能好?
干杯:
>[TestMethod]
public void TestMethod1()
{
CoreAppXmlConfiguration.Instance.RawElementBasedSearch = true;
CoreAppXmlConfiguration.Instance.MaxElementSearchDepth = 2;
var applicationDirectory = "D:\\Software\\ABC Handling System";
var applicationPath = Path.Combine(applicationDirectory, "ABCClient.GUI.exe");
Application application = Application.Launch(applicationPath);
Thread.Sleep(5000);
Window window = application.GetWindow("[AB2] - ABC Handling System 2 - [Entity Search]", InitializeOption.NoCache);
ListBox listbox = window.Get<ListBox>();
ListItem dispatchButton = listbox.Items.Find(i=>i.Name.Equals("Display"));
dispatchButton.Click();
Thread.Sleep(5000);
SearchCriteria sc = SearchCriteria.ByControlType(ControlType.Pane).AndIndex(3);
UIItemContainer groupbox = (UIItemContainer)window.MdiChild(sc);
UIItemContainer pane1 = null;
foreach (IUIItem automationElement in groupbox.Items)
{
if (automationElement.Name == "radSplitContainer1")
{
pane1 = (UIItemContainer)automationElement;
break;
}
}
UIItemContainer pane2 = null;
foreach (IUIItem automationElement in pane1.Items)
{
if (automationElement.Name == "splitPanel1")
{
pane2 = (UIItemContainer)automationElement;
break;
}
}
Table table = null;
foreach (IUIItem automationElement in pane2.Items)
{
if (automationElement.Name == "Telerik.WinControls.UI.RadGridView ; 247;14")
{
table = (Table)automationElement;
break;
}
}
TableRow row = table.Rows[9];
string s = row.ToString();
}
2019 年 5 月 11 日更新:
事实证明,就性能而言,TestStack White 并不是我的多行网格应用程序的最佳解决方案。
实际上,我们设法由开发人员从网格方面开发了一些东西,并将这些功能连接起来。所以我们使用 AutoIt + Customized Application side hooks。那里有一些非常好的控件。
是的,我们成功地采用了这种方法。
【问题讨论】:
标签: c# winforms ui-automation white-framework