Read Datagrid items/cell

Apr 8, 2010 at 10:13 AM

hi all ,

again i m facing problem because Datagrid have no Automation id and name.

how to read Datagrid item/cell.

Apr 8, 2010 at 10:58 AM
Edited Apr 8, 2010 at 11:06 AM

if this is the only datagrid in the view

 

use

 

ListView view = parent.Get<ListView>(SearchCriteria.ByControlType(ControlType.DataGrid));

 

if it is a direct child of the parent element and there are no other children (see UIAVerify or UISpy)


AutomationElement element = parent.AutomationElement.FindFirst( TreeScope.Children, new PropertyCondition( AutomationElement.ControlTypeProperty, ControlType.DataGrid ) );

ListView view = new ListView(element, parent.ActionListener);

 

if not


AutomationElementCollection coll = parent.AutomationElement.FindAll( TreeScope.Children, new PropertyCondition( AutomationElement.ControlTypeProperty, ControlType.DataGrid ) );

List views = new List();

foreach(AutomationElement element in coll)
{
  views.Add(new ListView(element, parent.ActionListener));
}

 

here you can now get the correct by Index