I'm using White to drive the UI of a WPF app, and it's worked well so far.
I'm at the point however, where I need to poke into the internal state of the app under test to check some conditions.
Specifically, I have a DataGrid (from the WPFToolkit), which is databound to a List<MyBusinessObject>
. Each row therefore has a DataContext
of a MyBusinessObject
I can get the grid using white by finding it with it's automation ID.
I can then do this:
var row = Grid.Rows[0]
row.AutomationElement.Current.Name
which returns the string "MyCompany.Namespace.MyBusinessObject"
, so I'm almost there, but I can't actually get the actual business object itself.
I've looked into WPF UIAutomation AutomationPeers (from an AutomationPeer
, you can get the Owner
property, which is the actual business object), but it seems that you need to be in-process to use these, as they all have constructors which require you to supply the WPF control.
Is there any way I can construct an AutomationPeer from an external process, or otherwise drill down into the actual DataContext
of a WPF control?