Ranorex

Problems automating Infragistics DataGrid control

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
prc



Joined: 08 Feb 2008
Posts: 1

PostPosted: Fri Feb 08, 2008 4:55 pm    Post subject: Problems automating Infragistics DataGrid control
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: click into code to enlarge
 
// 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();
     }
}
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 256

PostPosted: Sun Feb 10, 2008 9:51 pm    Post subject:
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.

Regards,
Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum