This is a migrated thread and some comments may be shown as answers.

CodedUI testing of contents of RadGridView

5 Answers 47 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ollie
Top achievements
Rank 1
Ollie asked on 09 Jan 2014, 01:44 PM
Hi,

I am trying to migrate a coded UI test to validate the contents of a RadGridView table which has replaced a WPF GridView control.  Previously the test retrieved the contents of the table something like;

 
 var grid = TableGrid;
 List<string> headers = new List<string>(from h in grid.ColumnHeaders.AsQueryable() select h.FriendlyName);
 int idColumn = headers.FindIndex(x => x == "Id") + 1;
 int productTypeColumn = headers.FindIndex(x => x == "Product Type") + 1;
 int titleColumn = headers.FindIndex(x => x == "Title") + 1;
 Collection<Collection<string>> contents = new Collection<Collection<string>>();
 foreach(var row in grid.Rows)
 {
     var cells = row.GetChildren();
     contents.Add(new Collection<string>() {
         cells[idColumn].FriendlyName, cells[productTypeColumn].FriendlyName, cells[titleColumn].FriendlyName });
 }
 return contents;

 
With RadGridView I can access the column headers and find out the number of rows, however there are no rows held against the table in the Rows property.  If I try to add a validation against a single cell in the coded UI test builder they appear to be under a separate hierarchy (UIPART_GridViewVirtualCustom).  

I can't create individual validations against each cell using the coded UI test builder as the volume of cells to validate makes that unwieldy so I need to be able to validate them programatically which we were able to do with the standard WPF GridView control through the Rows property.

Can anyone provide any suggestions as how I can programatically check the RadGridView contents using codedUI.

Thanks in advance

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 14 Jan 2014, 11:34 AM
Hi Ollie,

Based on the information you provided, I am not quite sure what exactly you do. Do you have tests for WPF DataGrid that work and want to transfer them to telerik RadGridView for WPF ? What are Rows property,UIPART_GridViewVirtualCustom ? How do you write your test - do you record them or create assertion tests ? 


Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Ollie
Top achievements
Rank 1
answered on 14 Jan 2014, 12:15 PM
Hi Maya,

Thanks for your response.

When we write our tests what we typically do is record steps and make assertions, then refactor the generated code into reusable classes that represent the actions that can be performed on individual pages of the application, and methods to access the data displayed at any particular time.  Our various test cases are then built up by placing calls onto our refactored page classes, rather than having to re-record anything or deal with the UIMap directly.

We had a set of CodedUI tests that for a given input data file then validated the entire contents of a WPF GridView table.  CodedUI provided the table as a Microsoft.VisualStudio.TestTools.UITesting.WpfControls.WpfTable which has a RowCount property that we used to validate the number of records.  Once we had mapped the control into the UIMap we then wrote a function which used the Rows property (which contained all the Rows and data in the table) to access all the individual rows in the table and extract all the data as strings to use in a cell-by-cell comparison.  This meant we didn't have to record an individual assertion for each cell in the table which would have been impractical.

When we moved to the Telerik RadGridView much of the codedUI test still worked with the RadGridView being returned as a Microsoft.VisualStudio.TestTools.UITesting.WpfControls.WpfTable, for example the RowCount property still returned the correct number of rows in the table.  However the Rows property returned 0 rows so we were unable to 'harvest' all the data from the RadGridView.  So we went looking to try and find if there was somewhere where all the data was stored for us to retrieve.  When placing an assertion on an individual cell and navigating up the hierarchy to try and identify the top level component that might 'hold' all the cells as data for us to programatically access we found that immediately below the gridTable was the UIPART_GridViewVirtualCustom control (ClassName: Uia.GridViewVirtualizingPanel, ControlType: Custom) which highlights all the cells in the table - however as ut was a Custom control type we couldn't seem to get anything from it.

We have now managed a workaround which uses Windows.Automation to find each cell in the grid and scroll down the table after processing each row to ensure that the next row is visible, however it's slightly clunky and if there were a way to access all the data through a codedUI object it would certainly be much neater and possibly run faster.

Does that answer your questions?

Thanks,

Ollie

0
Maya
Telerik team
answered on 17 Jan 2014, 03:33 PM
Hello Ollie,

Thanks a lot for the details information. Will it be possible to specify which version of RadControls you are working with since we made some improvements on that field ? If it is not the latest, can you please try with it ? 

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Ollie
Top achievements
Rank 1
answered on 20 Jan 2014, 08:23 AM
Hi Maya,

We are using 2013.3.1204.40 binaries for .Net 4.0

Thanks,

Ollie

 
0
Ivan Ivanov
Telerik team
answered on 23 Jan 2014, 01:30 PM
Hello,

Thanks for the provided clarifications. Basically, you are right about the current state of Uia.GridViewVirtualizingPanel - it does not expose much testable functionality. However, compatibility between legacy tests based on other DataGrid controls and RadGridView, will be quite difficult to achieve. For instance WPF DataGrid's automation logic, utilizes a mechanism that relies on the fact that the table control inherits from ItemsControl. As RadGridView does not inherit from ItemsControl, we are using our own custom logic.

Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Ollie
Top achievements
Rank 1
Answers by
Maya
Telerik team
Ollie
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or