It seems to be a problem if I want to access sub rows and sub cells of the DataGrid.
The Element.FindChildren method sometimes returns wrong elements, which I’ve already accessed within a loop.
I’m using the current Ranorex V1.3.1 version. Has anyone made the same experiences? Is this a known issue?
Code: Select all
// Find child by control name
control = form.FindClassName("WindowsForms10.Window.8.app.0.378734a");
control.Focus();
Element table = control.Element.FindChild(Role.Table,"ultraGrid1");
Element[] rows = table.FindChildren(Role.Row);
Console.WriteLine("RowCount: " + rows.Length.ToString());
int i = 0;
int j = 0;
foreach ( Element row in rows )
{
Element[] cells = row.FindChildren(Role.Cell);
foreach (Element cell in cells)
{
if (cell.State == State.Invisible)
continue;
Mouse.MoveToElement(cell);
cell.Value = "Cell: " + i.ToString() + "," + j.ToString();
j++;
}
j = 0;
i++;
row.DoDefaultAction();
Element[] subRows = row.FindChildren(Role.Row);
Console.WriteLine("SubRows: " + subRows.Length.ToString());
int k = 0;
int l = 0;
foreach (Element subRow in subRows)
{
Element[] rowCells = subRow.FindChildren(Role.Cell);
foreach (Element cell in rowCells)
{
if (cell.State == State.Invisible)
continue;
Mouse.MoveToElement(cell);
cell.Value = "Sub Cell: " + k.ToString() + "," + l.ToString();
l++;
}
k++;
l=0;
}
k=0;
row.DoDefaultAction();
}
}