Saturday 23 February 2013

Microsoft Test Manager fails to Record Clicks on Bound WPF DataGridView

I recently ran into a problem when using Microsoft Test Manager for UI testing. When clicking on a row in a Bound DataGridView, I would receive a warning that a step couldn’t be recorded.

Then, when I imported the test into Visual Studio when I wanted to convert it to an Automated Test, that step would report;

Last action on Row was not recorded because the control does not have any good identification property.

After a quick search, I came across a Microsoft blog which describes how to rectify this issue;

http://blogs.msdn.com/b/gautamg/archive/2010/03/10/how-to-get-automation-working-properly-on-data-bound-wpf-list-or-combo-box.aspx

Basically, the issue is that the Test Manager resolves clicks in DataGrids and Lists by calling the .ToString() method on the item. If this function doesn’t return anything meaningful that the Test Manager can use, then the step isn’t recorded.

As I had bound my WPF DataGridView to an Observable Collection of Entities, I was simply able to override the .ToString() method in the Buddy Class for the Entity, which solved the problem quite nicely.

No comments:

Post a Comment