Dec 1, 2012 at 2:53 PM
Edited Dec 1, 2012 at 2:59 PM
The WPF application I'm automating has DataGrid control. Almost all the times listView.Rows returns 0, despite of there are several rows. Number of Columns is correct. I tried to do the same using UIA, but the result was the same. So it's not a white problem.
All the UI Spies show correct Rows/Columns numbers (!). Looks like for some reasons I get the state of the grid when it is just loaded, when rows count is 0. Also interesting, that 1 time both White and UIA were able to detect correct number of rows / columns
after I just reopen the solution. But all next times after that this workaround has not helped..
Have anyone ever faced with such a problem in White / UIA ?
Window windowMain = UiaHelper.WaitObject(SprinterHelper.GetSprinterWindow);
ListView listTests = windowMain.Get<ListView>(ControlsHelper.Controls[C.RunMode_TestsListView]);
ListViewHeader header = listTests.Header;
ListViewColumn columnName = header.Column("Name");
int indexOfNameColumn = columnName.Index;
// Rows.Count is always == 0... But Spies show correct number.. ??
List<string> testNames = listTests.Rows.Select(r => r.Cells[indexOfNameColumn].Text).ToList();
Sorry, my fault, there where 2 controls with the same properties, one visible, and other invisible. I have written an extension method which lacks in White to solve this problem:
public static T GetMultiple<T>(this UIItemContainer container, SearchCriteria criteria, VisibilityScope visibility) where T : UIItem
IUIItem allItems = container.GetMultiple(criteria);
return allItems.Where(i => i.Visible == (visibility == VisibilityScope.Visible)).Cast<T>().ToArray();