如何使用Coded UI计算表中的行

时间:2016-08-10 14:22:42

标签: c# coded-ui-tests

我正在尝试计算由我们的应用程序动态生成的WinTable中的行数。我希望它会像使用下面的代码一样简单,但前两个'计数返回0.第三个返回3,即使生成了50多行。也许这个数字是Table Header,Table Rows等等?

WinTable OrderTable = UIApp.UIItemWindow.UIItemTable;
int count1 = OrderTable.Rows.Count();
int count2 = OrderTable.Rows.Count;
UITestControlCollection temp = OrderTable.GetChildren();
var count3 = temp.Count();
Console.WriteLine("Number of Rows: {0}, {1}, {2}", count1, count2, count3);

Output:
Number of Rows: 0,0,3

在任何情况下,有没有办法通过Coded UI来计算WinTable中的行?

1 个答案:

答案 0 :(得分:0)

我发现WinTable对象中还有另一个级别。

WinClient OrderRows= UIApp.UIItemWindow.UIItemTable.UIDataPanelClient;
UITestControlCollection count = OrderRows.GetChildren();
var a = count.Count;
Console.WriteLine("Number of Rows: {0}", count);

Output: 
Number of Rows: 456

这看起来更接近正确的值。