使用 Coded ui 检索特定行的网格计数

Retrieving Grid count for particular rows using Coded ui

我有一个 grid.I 想要获取特定行的网格计数,不包括特定 value.how 的行,我可以使用 Coded UI 获取这种情况下的网格计数吗?

我会创建一个列表,然后遍历您的行集合并将符合您需要的行添加到列表中。然后,只需计算列表中的对象即可。

UITestControlCollection myRows = rowDefinition.FindMatchingControls();
list<string> matchingRows = new list<string>();

foreach (UITestControl control in myRows)
{
    if (!control.GetProperty("InnerText").ToString().Contains("myValue"))
        matchingRows.Add(control.GetProperty("ID").ToString());
}

int theRowsIWant = matchingRows.Count;