Unable to access datagridcell in datagrid

Nov 13, 2008 at 12:08 AM
i creat a sliverlight application, and contain a "DataGrid" control.then use White to test.

the below code can be valid, "DataGrid" control can be found and datagridrows can be found too:
ListView dataView = window.Get<ListView>(SearchCriteria.ByAutomationId("dataGrid"));
dataView.Select(2);

but the datagridcell can not found, the cells are empty(System.ArgumentOutOfRangeException );
string name = dataView.Rows[0].Cells[0].Name;

Moreover,
1.if use "Table" UIItems to search the "DataGrid" control, the result is null;
2.if user "Label" UIItems to search the DataGridCell by name, the way can be successful;

Now, i want to abtain information in a row, and check it;
Please let me know if there's anything else you need, thank you firstly!
Coordinator
Nov 15, 2008 at 6:20 PM
I think using ListView is the right thing.
In order to investigate it, Can you please do x.LogStructure() and send me the console output. Please attach this in a file so that I can see the indentations.
Nov 24, 2008 at 7:50 AM
Hi forlu,

You wrote that you use white for testing silverlight application. How do you add white references in the SL app?
When I tried to add a reference- I receive an error: "You cannot add reference to Core.dll as it was not built against SL runtime..."

Thanks in advance.
Coordinator
Nov 25, 2008 at 2:43 AM
You dont need to add white dlls reference to Application Under Test. You need to create a separate project for it.
Nov 26, 2008 at 6:50 PM
We're in the same exact position.

Our grid does not have an automationid, so we get it by searching for type "datagrid" on the page.

This is the code we use:

ListView

listview = window.Get<ListView>(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.DataGrid));

The results were the same as mentioned above. We were only able to see empty cells.

What is x.logstructure?

 

Coordinator
Dec 5, 2008 at 2:55 PM
sorry for late response...
i mean can you send me the output dataView.LogStructure()
Dec 11, 2008 at 8:47 PM
What is the best way to access a cell in a datagrid? We have a simple data grid and I am unable to access a specific cell. What do you recommend?
Dec 11, 2008 at 8:47 PM
What is the best way to access a cell in a datagrid? We have a simple data grid and I am unable to access a specific cell. What do you recommend?
Coordinator
Dec 14, 2008 at 8:04 AM
how are you trying to access a cell?
Dec 15, 2008 at 6:46 PM
Hi Vivek,
I'm using the following code to access the grid:

ListView

dataGrid = mainWindow.Get<ListView>(SearchCriteria.ByAutomationId("MyDataGrid"));

 

If I look at a specific row:

row = dataGrid.Row[x]

I can't see a specific column in row. I'm not sure if it's something I'm doing wrong, or if it's by design.

Thanks for all the responses,
Vincent

Coordinator
Dec 23, 2008 at 12:03 PM
there is no method like Row[..] in ListView class. was that a typo.