Problems automating Infragistics DataGrid control

Class library usage, coding and language questions.
Posts: 1
Joined: Fri Feb 08, 2008 3:52 pm

Problems automating Infragistics DataGrid control

Post by prc » Fri Feb 08, 2008 3:55 pm

I use the element approach to automate an Infragistics DataGrid control.
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("");
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)

          cell.Value = "Cell: " + i.ToString() + "," + j.ToString();
        j = 0;
        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)
                  cell.Value = "Sub Cell: " + k.ToString() + "," + l.ToString();

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Sun Feb 10, 2008 8:51 pm

You are right, this is a known issue of the Element caching algorithm in version 1.3.1. There's the chance of an ambiguity if two elements have exactly the same properties (i.e. Name, Role, Position, Description, corresponding Control).

This is rather unusual, but may happen e.g. if the GUI changes its outline (reacting to some user input) and an element having exactly the same properties comes to lie at the same position where's the former element has been.

In Ranorex version 1.4 the caching algorithm has been revised and this flaw has been resolved. An Element object will then always refer to the same GUI element.

Ranorex Support Team