This project is read-only.

DataGridView... sigh

Feb 2, 2012 at 12:44 AM

Hi, I'm very new to .Net and just trying out some automation with White. I'm loving it but hitting a wall trying to read data from a datagridview. I've read a bunch of posts here about the problem but haven't been able to solve the problem. A bit of friendly help would be much appreciated.


Table grid = mainWindow.Get<Table>("dgvItems");


This code works for me on a table with 7 items but it doesn't work on a larger table within the same app. By "doesn't work" I mean the console just sits there forever, I didn't wait longer than 5 minutes. So if I try limiting the search depth, once again it works on the small table, but not on the larger:

Table grid = mainWindow.Get<Table>("dgvMarketSearch");

CoreAppXmlConfiguration.Instance.RawElementBasedSearch = true;
CoreAppXmlConfiguration.Instance.MaxElementSearchDepth = 9;


CoreAppXmlConfiguration.Instance.RawElementBasedSearch = false;

My depth is 9 because that's where the tables are. Is this my problem? I can't change the app, I'm just trying to read data from it. Anything else I can try?

Feb 9, 2012 at 4:01 PM


A couple of points:

  • White performance with DataGridView is sadly not very good. You probably won't want to do tests with a very large database, unless it's absolutely required for some tests.
  • Change the BusyTimeout config to a higher value. That's the time White will wait to find your DataGridView or get the rows. If it doesn't find it, it would try again infinitely. For your first tests i would put a very large value to make sure you don't hit this problem (let's say 1 minute).
  • One strategy you can use to get the DataGridView with better performance: Get a parent control first, and then get the DataGridView, relative to this parent control.

Let's say this DataGridView is inside a Panel at depth 8. You can get the Panel first:

CoreAppXmlConfiguration.Instance.MaxElementSearchDepth = 8;
 Panel myPanel = mainWindow.Get<Panel>(SearchCriteria.ByAutomationId("myPanel"));

Then you can get the DataGridView, directly under this panel (depth 1);
CoreAppXmlConfiguration.Instance.MaxElementSearchDepth = 1;
Table grid = myPanel.Get<Table>("dgvMarketSearch");

Feb 11, 2012 at 5:11 PM

Thanks for the suggestions! Something strange though - doing max depth 8 and then 1 relative to the panel returns empty table rows (correct number of rows, but no data). 8 + 2 relative works like max depth 9...

As for speed, 39 rows took 15 minutes. I tried 280 rows and after an hour and a half it crashed with an error when it ran out of RAM (there was 2 GB available before the test, 0 bytes at time of crash). The table data is about 40 KB so it's probably not the table's fault.

Feb 11, 2012 at 6:40 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.