I'm trying to automate a certain control (Telerik's Rad GridView) with Microsoft's UIA. I have created a wrapper class that exposes several helper methods for my test to use - the most prominent example being a GetAllRows() method that returns a collection of all grid rows.
My problem is that this particular control is virtualized, meaning that only the visible rows are rendered and represented in the UI at any given time. To get all rows, I'm forced to use the ScrollPattern and repeatedly scroll down until I reach a 100% scroll, each time requesting all child row elements. Besides this being sheer ugly code, I'm also faced with the problem of removing rows that were picked up several times, which is complicated because in this particular grid, duplicate values are allowed.
Microsoft recommends using the ItemContainer pattern which allows to request all AutomationElements under a particular control given a condition, regardless of whether or not they're virtualized. You can then use the VirtualizedItemPattern's Realize() method to bring the AutomationElement into view and render it.
This would have worked, unfortunately Telerik have not implemented this Control Pattern for their Grid View, and even if they did, I would have problems using it as grid rows are not getting a unique AutomationId which makes it hard to formulate a Condition object which the ItemContainer pattern would utilize.
Does anyone have any idea on how would this be possible more elegantly? I don't have a problem with implementing a "scroller" method to render the rows, but I don't want to deal with removing duplicate AutomationElements.