Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing DataGridView Cells via White

So I'm doing some C# automation/UI testing with White and am having trouble with something. I have a DataGridView in the app and I set the background cell colors differently depending on application state. I want to check these colors during tests using White, but am having trouble doing so.

Here's what I'm trying to make work. I can get the grid view, but only as a table. Then, I have problems later on because I end up with plain TableCells instead of DataGridViewCells.

var Table = MainWindow.Window.Get<Table>("DataGridViewName");
var Row = Table.Rows[0];
var Cell = Row.Cells[0];
//invalid
//var Color = Cell.Style.BackColor;

Has anybody run into this before or have any suggestions?

like image 447
sshannin Avatar asked Aug 31 '12 18:08

sshannin


1 Answers

Are you sure backcolor is exposed through UI Automation? From the low-level UI Automation coding I've done, I have never seen such a property. I just opened Inspect (similar to UISpy) and pointed it at a DataGridView in a C# WinForms app, and no such property is exposed.

So since it doesn't seem to be exposed, there is no way to figure it out through automation, short of capturing an image and comparing it to some baseline with some threshold (sounds like a mess).

Unless you can somehow embed the information in some other automation property (which would require changing the app under test), I don't see any way to do it. :(

like image 104
Samer Adra Avatar answered Oct 05 '22 19:10

Samer Adra