How to get all rows from virtualized gridview using CodedUI

2 posts, 0 answers
  1. Denis
    Denis avatar
    1 posts
    Member since:
    Jun 2014

    Posted 27 Aug 2014 Link to this post

    I develop automated tests using MS VS 2012 and CodedUI. Our application contains number of teleriks gridviews. For test purposes I need to obtain every row from those gridviews, but the problem is I can only obtain limited number of rows due to virtualization. Tried scrolling new rows into view to realize them and adding them to array/collection
    code snippet:

    // determine viewport, i.e. how many rows are accessible for that specific panel
                 
                for (int m = 0; m < 50; m++)
                {
                    try
                    {
                        if (!hGridView.GetRow(m).Exists)
                        {
                        }
                    }
                    catch (UITestControlNotFoundException)
                    {
                        viewPort = m - 1;
                        break;
                    }
                }
     
                // no extra scrolling required, all rows are accessible
                if (rowCount <= viewPort + 1)
                {
                    for (int m = 0; m < rowCount; m++)
                    {
                        rows_output[m] = hGridView.GetRow(m);
                    }
                    return rows_output;
                }
     
                //get all accessible rows before scrolling to expose the rest
                for (int m = 0; m <= viewPort; m++)
                    {  
                        rows_output[m] = hGridView.GetRow(m);
                        col1.Add(hGridView.GetRow(m));
                    }
     
                for (int m = 0; m < viewPort; m++) { Keyboard.SendKeys("{DOWN}"); }
                 
                for (int i = 0; i <= rowCount - viewPort - 2; i++)
                {
                     
                    try
                    {
                        // check the row to add isn't a duplicate
                        if (!col1.Contains(hGridView.GetRow(viewPort)))
                        {
                            col1.Add(hGridView.GetRow(viewPort));
                        }
     
                        rows_output[i + viewPort + 1] = hGridView.GetRow(viewPort);
                    }
                    catch (UITestControlNotFoundException)
                    {
                        // if for some reason gridview becomes inaccessible
                        break;
                    }
     
                    //scroll the grid down a bit
                    Keyboard.SendKeys("{DOWN}");
     
                }
    code works ok when i'm debugging, but when i'm just running the test resulting array is mess, the same ~10 rows repeats again and again
    What's wrong with this code? Is there any other reliable way to get all the data from virtualized grid?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 Aug 2014 Link to this post

    Hi,

    If the row is not in the View port, then there is not GridviewRow realized for displaying the respective Item. When the virtualization of RadGridView is turned on (which is by default), its elements are created when they should be brought into view. You can take a look at this article for a reference on UI Virtualization.

    May I ask you why do you need to access all the GridViewRows? What level do you use?

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top