Jem003
Jem003

Reputation: 41

Retrieving Grid count for particular rows using Coded ui

I am possessing a grid.I want to get the Grid Count for particular rows excluding the rows of a particular value.how can I get the grid count for such condition using Coded UI ?

Upvotes: 2

Views: 182

Answers (1)

Ryan Cox
Ryan Cox

Reputation: 958

I'd create a list, then loop through a collection of your rows and add the rows that match your needs to the list. Then, just count the objects in the list.

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;

Upvotes: 2

Related Questions