Datagrid

Apr 16, 2008 at 4:38 PM
Application app = Application.Attach("WinFormsTestApp");
var p = app.GetWindow("Form1",Core.Factory.InitializeOption.NoCache).Get<Table>("people");
TableRows r = p.Rows;

I tried this with the sample winform app and i get an Nullreference exception.

How do i get data from the datagrid?

Am i doing something wrong?
Coordinator
Apr 16, 2008 at 6:19 PM
which line are you getting null reference at?
Apr 16, 2008 at 11:09 PM
TableRows r = p.Rows;

This is the line.
Apr 17, 2008 at 4:25 PM

naveensrinivasan wrote:
TableRows r = p.Rows;

This is the line.


public virtual TableHeader Header
{
get
{
if (header == null) header = (TableHeader) new TableHeaderFactory().Create(finder.Descendant(SearchCriteria.ByText("Top Row")), actionListener);
return header;
}
}
I see from the source code of White , the code is looking for Descendant name "Top Row" and when it doesn't find that header happens to be null and
tableheader in turn calls the UIItem which throws the exception.

Core.dll!Core.UIItems.UIItem.UIItem(System.Windows.Automation.AutomationElement automationElement = null, Core.UIItems.Actions.ActionListener actionListener = {Form1}) Line 35 C#
> Core.dll!Core.UIItems.TableItems.TableHeader.TableHeader(System.Windows.Automation.AutomationElement automationElement = null, Core.UIItems.Actions.ActionListener actionListener = {Form1}) Line 13 + 0xc bytes C#
Core.dll!Core.Factory.TableHeaderFactory.Create(System.Windows.Automation.AutomationElement automationElement = null, Core.UIItems.Actions.ActionListener actionListener = {Form1}) Line 12 + 0x18 bytes C#
Core.dll!Core.UIItems.TableItems.Table.Header.get() Line 41 + 0x52 bytes C#
Core.dll!Core.UIItems.TableItems.Table.Rows.get() Line 31 + 0x15 bytes C#

Coordinator
Apr 18, 2008 at 3:08 AM
May be there is something in the structure of Table which white is not aware of till now.
Can you please do a Debug.Details(table.AutomationElement) and send it me? This would help me provide a fix
Apr 18, 2008 at 1:27 PM

viveksingh wrote:
May be there is something in the structure of Table which white is not aware of till now.
Can you please do a Debug.Details(table.AutomationElement) and send it me? This would help me provide a fix

Here you go. Do you have any sample code to get details of a datagrid? I would really appreciate that.
AutomationId: people
ControlType: table
Name: DataGridView
HelpText:
Bounding rectangle: 1509,247,599,150
ClassName: WindowsForms10.Window.8.app.0.33c0d9d
IsOffScreen: False
IsOffScreen: False

AutomationId: 659582
ControlType: pane
Name: Vertical Scroll Bar
HelpText:
Bounding rectangle: 2091,248,16,148
ClassName: WindowsForms10.SCROLLBAR.app.0.33c0d9d
IsOffScreen: False
IsOffScreen: False

Coordinator
Apr 18, 2008 at 5:19 PM
There is no issue with your code.
This seems to be a UIAutomation issue. For some reason on your machine you are not able to see the details of Table. e.g. On my machine I see this it like this.
Can you send across the version of windows you are using and maybe send me what you see when you run winver command. I would want to raise an issue about this with MS forum on UIAutomation.

TableTest.Find : PassedAutomationId: people
ControlType: table
Name: DataGridView
HelpText:
Bounding rectangle: 229,247,599,150
ClassName: WindowsForms10.Window.8.app.0.33c0d9d
IsOffScreen: False

AutomationId: 2494832
ControlType: pane
Name: Vertical Scroll Bar
HelpText:
Bounding rectangle: 811,248,16,148
ClassName: WindowsForms10.SCROLLBAR.app.0.33c0d9d
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Top Row
HelpText:
Bounding rectangle: 230,248,581,18
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Top Left Header Cell
HelpText: DataGridViewTopLeftHeaderCell(DataGridViewColumnHeaderCell)
Bounding rectangle: 230,248,41,18
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Name
HelpText: DataGridViewColumnHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 271,248,100,18
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Country
HelpText: DataGridViewColumnHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 371,248,100,18
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Alive
HelpText: DataGridViewColumnHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 471,248,100,18
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Display
HelpText: DataGridViewColumnHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 571,248,100,18
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Details
HelpText: DataGridViewColumnHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 671,248,100,18
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Row 0
HelpText:
Bounding rectangle: 230,266,581,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Row 0
HelpText: DataGridViewRowHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 230,266,41,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Name Row 0
HelpText: DataGridViewTextBoxCell(DataGridViewCell)
Bounding rectangle: 271,266,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Country Row 0
HelpText: DataGridViewComboBoxCell(DataGridViewCell)
Bounding rectangle: 371,266,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Alive Row 0
HelpText: DataGridViewCheckBoxCell(DataGridViewCell)
Bounding rectangle: 471,266,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Display Row 0
HelpText: DataGridViewButtonCell(DataGridViewCell)
Bounding rectangle: 571,266,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Details Row 0
HelpText: DataGridViewLinkCell(DataGridViewCell)
Bounding rectangle: 671,266,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Row 1
HelpText:
Bounding rectangle: 230,288,581,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Row 1
HelpText: DataGridViewRowHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 230,288,41,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Name Row 1
HelpText: DataGridViewTextBoxCell(DataGridViewCell)
Bounding rectangle: 271,288,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Country Row 1
HelpText: DataGridViewComboBoxCell(DataGridViewCell)
Bounding rectangle: 371,288,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Alive Row 1
HelpText: DataGridViewCheckBoxCell(DataGridViewCell)
Bounding rectangle: 471,288,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Display Row 1
HelpText: DataGridViewButtonCell(DataGridViewCell)
Bounding rectangle: 571,288,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Details Row 1
HelpText: DataGridViewLinkCell(DataGridViewCell)
Bounding rectangle: 671,288,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Row 2
HelpText:
Bounding rectangle: 230,310,581,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Row 2
HelpText: DataGridViewRowHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 230,310,41,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Name Row 2
HelpText: DataGridViewTextBoxCell(DataGridViewCell)
Bounding rectangle: 271,310,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Country Row 2
HelpText: DataGridViewComboBoxCell(DataGridViewCell)
Bounding rectangle: 371,310,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Alive Row 2
HelpText: DataGridViewCheckBoxCell(DataGridViewCell)
Bounding rectangle: 471,310,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Display Row 2
HelpText: DataGridViewButtonCell(DataGridViewCell)
Bounding rectangle: 571,310,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Details Row 2
HelpText: DataGridViewLinkCell(DataGridViewCell)
Bounding rectangle: 671,310,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Row 3
HelpText:
Bounding rectangle: 230,332,581,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: header
Name: Row 3
HelpText: DataGridViewRowHeaderCell(DataGridViewHeaderCell)
Bounding rectangle: 230,332,41,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Name Row 3
HelpText: DataGridViewTextBoxCell(DataGridViewCell)
Bounding rectangle: 271,332,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Country Row 3
HelpText: DataGridViewComboBoxCell(DataGridViewCell)
Bounding rectangle: 371,332,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Alive Row 3
HelpText: DataGridViewCheckBoxCell(DataGridViewCell)
Bounding rectangle: 471,332,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Display Row 3
HelpText: DataGridViewButtonCell(DataGridViewCell)
Bounding rectangle: 571,332,100,22
ClassName:
IsOffScreen: False

AutomationId:
ControlType: custom
Name: Details Row 3
HelpText: DataGridViewLinkCell(DataGridViewCell)
Bounding rectangle: 671,332,100,22
ClassName:
IsOffScreen: False
Apr 18, 2008 at 5:39 PM
Edited Apr 18, 2008 at 5:54 PM
Windows XP
Windows Version 5.1 SP 2
Build 2600.xpsp2_qfe.070227-2300

This is also happening on Windows 2003 Server SP2. Why do you think this has something to do with OS?

Coordinator
Apr 19, 2008 at 9:06 PM
There is a similar issue like this for MenuBar and ToolBar. But this one looks different if your version is same as mine.
Can you check the version of UIAutomationClient in your gac? the version I have is 3.0.0.0 with token as 31bf3856ad364e35
Apr 19, 2008 at 9:49 PM
3.0.0.0 31bf3856ad364e35 MSIL UIAutomationProvider

I also have the same version.
Coordinator
Apr 21, 2008 at 5:13 AM
I have raised an issue regarding this in UIAutomation forum. I donot hope to get an answer, but it is fundamentally UIA issue and I cannot do much to solve it.
I hope you are trying to run the unit tests that come with white?
If not can you send me your code which I can run and see, why it is failing.
Jul 8, 2008 at 11:53 AM

I have the same problem when try to access to Rows property. But TableRowsTest passed.

Code:
Application app = Application.Attach("WinFormsTestApp");

Window win = app.Get("Form1", InitializeOption.NoCache);

Table userGridTable = (Table) win.Get<Table>("people");

TableRows rows = userGridTable.Rows;

Have you found any decision?

Coordinator
Jul 8, 2008 at 2:27 PM
Nothing from MS UIA team as I expected.
I would leave this issue open though.
Jan 13, 2009 at 9:34 PM
Has there been any resolution to this problem? I was previously able to access Datagridview cells, however over the Christmas break my code has started to display the above error when attempting to access table.Rows, and when logging the structure of the table no children elements are shown in the output.
I have created a very basic test that attempts to access the rows of the DataGridView in the sample application WinFormsTestApp, which still fails, however when running the suite of tests that come with White, accessing the table.Rows succeeds. Given that I built both suites on the same computer, I would be interested if anyone has any ideas why one can see table children and the other cannot.
Coordinator
Jan 23, 2009 at 11:45 AM
When you say you were able to access the DGV cells, have you changed your machine since then. There is a known issue with DGV, really with UIA.
Jan 26, 2009 at 9:22 PM
Apart from a Windows update, my machine had not been modified in between. I was however, able to resolve my problem as per the solution suggested by this issue thread, which additionally allowed me to find children of winforms menubars, which I was having trouble with.
Jan 13, 2010 at 1:45 PM
Edited Jan 13, 2010 at 3:20 PM

Hi,

Any new updates on this issues? I believe I might be facing the same problem since the logStructure() output only reveals a Horizontal Scroll Bar (as seen on UISpy also) inside the DataGridView/Table.

 ControlType: ControlType.Table
Name: DataGridView
HelpText:
Bounding rectangle: 324;212;707;461
ClassName: WindowsForms10.Window.8.app.0.378734a
IsOffScreen: False
FrameworkId: WinForm
ProcessId: 5936


    AutomationId: 1444940
    ControlType: ControlType.Pane
    Name: Horizontal Scroll Bar
    HelpText:
    Bounding rectangle: 326;655;703;16
    ClassName: WindowsForms10.SCROLLBAR.app.0.378734a
    IsOffScreen: False
    FrameworkId: WinForm
    ProcessId: 5936

Tried setting ApartmentState to STA, but didn't solve. Still get Count 0 on the Table element. Can it be because it doesn't show the TopRow or Header elements that UIA uses?

Windows version is Microsoft Windows XP [Version 5.1.2600]