Get a DataGrid/Table

May 15, 2008 at 7:54 PM
Any suggestions for how to debug problems with 'Get()' not working for a Table.  The table is found by UISpy as shown below (I've replaced the text of somethings with XXX or YYY to avoid exposing customer information).  Code like in the unit tests does not find the Table, e.g., 

Core.

Application application = Core.Application.Attach("EXENAME");

 

Core.UIItems.WindowItems.

Window window = application.Find(delegate(string obj) { return obj.StartsWith("PATH"); }, Core.Factory.InitializeOption.NoCache);

 

 

Tab tab = window.Get<Tab>();

 

selectTab(tab,

"Templates");

 

 

Table table = window.Get<Table>("1004");

 

 

Assert.IsNotNull(table);


I successfully attach to the window and navigate to the corret tab but 'table' is always null.  I've tried using: window.Get<Table>("XXX"); and window.Get<Table>(); but the results are the same.  Do I need to do something special because there is a tab?  The data grid is a child of the window, not of the tab.  I've also had the same problem on another window where the Data Grid is a child of the tab. 

 



AutomationElement

General Accessibility

AccessKey: ""

AcceleratorKey: ""

IsKeyboardFocusable: "True"

LabeledBy: ""text" "XXX Management: Templates""

HelpText: ""

State

IsEnabled: "True"

HasKeyboardFocus: "False"

Identification

ClassName: "SysListView32"

ControlType: "ControlType.DataGrid"

Culture: "(null)"

AutomationId: "1004"

LocalizedControlType: "data grid"

Name: "XXX"

ProcessId: "7076 (YYY)"

RuntimeId: "42 5837638"

IsPassword: "False"

IsControlElement: "True"

IsContentElement: "True"

Visibility

BoundingRectangle: "(113, 182, 892, 453)"

ClickablePoint: "(null)"

IsOffscreen: "False"

ControlPatterns

Grid

RowCount: "1"

ColumnCount: "8"

MultipleView

CurrentView: "0"

SupportedViews: "0"

Selection

Selection: ""

CanSelectMultiple: "False"

IsSelectionRequired: "False"

Table

RowHeaders: ""

ColumnHeaders: ""header item" "Template Name" "header item" "XXX Type" "header item" "XXX Subtype" "header item" "YYY" "header item" "XXXApprover" "header item" "XXX YYY" "header item" "Entered" "header item" "Entered by""

RowOrColumnMajor: "RowMajor"

RowCount: "1"

ColumnCount: "8"

May 16, 2008 at 5:54 PM
I think my question is whether I need to do something different when trying to access a control type that UISpy shows as a DataGrid rather than as a Table.  When I write a new application any DataGrid or DataGridView controls are shown by UISpy as being ControlType.Table.  I'm trying to drive an application that I don't have the source code for and which was built an unknown amount of time ago.  UISpy shows the 'tables' in the application I want to tests UI as ControlType.DataGrid.  Calling window.Get<Table>("1004");  or other variations on calling 'Get' never find the control. 
May 16, 2008 at 8:59 PM
I think my question is whether I need to do something different when trying to access a control type that UISpy shows as a DataGrid rather than as a Table.  When I write a new application any DataGrid or DataGridView controls are shown by UISpy as being ControlType.Table.  I'm trying to drive an application that I don't have the source code for and which was built an unknown amount of time ago.  UISpy shows the 'tables' in the application I want to tests UI as ControlType.DataGrid.  Calling window.Get<Table>("1004");  or other variations on calling 'Get' never find the control. 
May 17, 2008 at 12:13 PM
From looking at the white code it looks like I should be looking for a 'ListView' instead of a 'Table' since the entry in ControlDictionary.items is:

items.Add(

ControlDictionaryItem.Primary(typeof (ListView), ControlType.DataGrid));

I can't test this till I'm on site at the customer again and I can't figure out how to create a test window that contains a DataGrid that shows up in UI Spy.  I'm using VS2008 and ListBox and ListView controls shows up as 'ControlType.List' to UISpy.  I'd appreciate confirmation from anyone that this is the right approach and suggestions for how to add a control to my test application that will show up as a DataGrid in UISpy or I'll just continue this self dialog as I figure it out. 

 

Coordinator
May 17, 2008 at 5:27 PM
Yes you do need to use ListView in this case.