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

时间:2015-06-10 17:46:58

标签: .net coded-ui-tests

我拥有一个网格。我想获取特定行的网格计数,不包括特定值的行。我可以使用编码的UI获取此类条件的网格数吗?

1 个答案:

答案 0 :(得分:2)

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

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;
相关问题