2

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.

Tal Bronfer
  • 759
  • 5
  • 18

2 Answers2

0

To follow up on my own question, I ended up just implementing code that scrolls until it gets all the elements. I take care of the duplicated values by always saving the last element before scrolling and thus finding out my actual position. It's not pretty, but it's fairly generic and reusable.

Tal Bronfer
  • 759
  • 5
  • 18
  • 1
    It would be extremely helpful if you could post your code as well. It will help me and others facing similar problem. – digitguy Feb 16 '15 at 08:39
0

You could have used ItemContainer without conditions, realizing items one-by-one and then test them in your code as usual. It'd have saved you work with scroll and waiting until item is realized after scrolling 'by itself'.

But without Telerik implement the pattern in the first place - I'm afraid working with scroll is the only option.

Ivan Danilov
  • 14,287
  • 6
  • 48
  • 66