Getting Specific Grid Row

3 posts, 0 answers
  1. Bill
    Bill avatar
    42 posts
    Member since:
    Feb 2011

    Posted 02 Aug 2012 Link to this post

    I was unsure if I should post this in the testing forum or the RadGridView forum.

    It is regarding Automated testing but more of a general question since our testers have decided to go with the IBM Rational Functional Tester (RFT) 8.2.2. since they test various types of apps- WPF, Web etc.

    Ours is a WPF app using Telerik WPF controls and Prism. Our testers have told us that they cannot select specific rows in a grid because the RadGrid rows do not have any unique attributes like UID or name.
    I verified that using Snoop and the IBM rational tool built into the testing tool which gives similar results to snoop. I use the RadGrid as an example but the same problem applies to other controls like RadTree for example. Since the grid rows are created at runtime, the GridRows do not contain the unique attributes to help the automated testing tool locate a row with specif text.

    So the question is who's problem is this? What I mean by that is do we fix it on the code side or expect the testers to figure out a way to do it on their side? I think we could fix it on the code side but before we do, (and possibly slow down the grid loading a bit) we want to ensure that that is the correct approach or do we leave it in the hands of the testers to worry about.

    On the code side I assume (unless theres a better way) to wait for the grid to finish loading and then run a method that iterates the rows/columns and adds a Name (or UID) attribute to each row with text from column X. So for example Row 1 would end up with Name="Bob Smith" taken from the Full Name column in the grid. Then the automated testing tool could find the row based on the name attribute.

    I don't know the IBM automated tool capabilities but I would think that it (and all testing tools) should be able to do a similar thing to locate a row from the tool itself.

    Comments???
  2. Jonas
    Jonas avatar
    20 posts
    Member since:
    Jun 2012

    Posted 03 Aug 2012 Link to this post

    Hello Bill,

    (From a testers point of view)
    I faced the same issue, and since there wasn't any good way to solve this i made some extensions in my TelerikTestStudio project.
    My Extensions are making it possible for me to quickly find controls, texts etc in grids, then it returns the cell or row containing the match so i can use it to nagivate through the grid and find the information that i want.

    If you use RadGridviewes containing alot of rows perhaps this is not the best way in solving this, but it works perfectly for my solution.
    And if it take a while to generate, remeber to user applicationWindow.myRadGridView.Wait.ForNoMotion() or something simular before using this methods.

    This is the extensions i use for the GridViewRow.
    public static GridViewCell GetCellContainingText(this GridViewRow gridViewRow, string text)
    {
         return gridViewRow.Cells.Where(c => c.Text == text).First();
    }
     
    public static GridViewCell GetCellByType<T>(this GridViewRow gridViewRow) where T : IFrameworkElement
    {
         return gridViewRow.Cells.Where(c => c.Find.ByType<T>() != null).FirstOrDefault();
    }
     
     public static IEnumerable<GridViewCell> GetAllCellByType<T>(this GridViewRow gridViewRow) where T : IFrameworkElement
    {
         return gridViewRow.Cells.Where(cell => cell.Find.ByType<T>() != null);
    }


    This for the RadGridView
    public static GridViewRow GetRowContainingText(this RadGridView gridView, string text)
            {
                return gridView.Rows.Do(row => row.Cells.Where(cell => cell.TextBlockContent == text)).FirstOrDefault();
            }
     
            public static GridViewRow GetRowContainingText(this RadGridView gridView, string text, int cell)
            {
                return gridView.Rows.Where(row => row.Cells[cell].TextBlockContent == text).FirstOrDefault();
            }
     
            public static GridViewCell GetCellContainingText(this RadGridView gridView, string text)
            {
                foreach (var cell in gridView.Rows.SelectMany(row => row.Cells))
                {
                    cell.Refresh();
                    if (cell.Find.AllByCustom(c => c.TextBlockContent.Contains(text)) != null)
                        return cell;
                }
                throw new ArgumentException("Can't find the cell containing " + text, "text");
            }

    Hope it will give you some tips about how to solve this.

    //Jonas
  3. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 07 Aug 2012 Link to this post

    Hello Bill,

    Since this forum is dedicated to Test Studio (specifically our Visual Studio plug-in) the most we, the Test Studio support team, can do for you is talk about and demonstrate how Test Studio can be used to automate the RadGridView. We can't help you with how to use IBM Rational Functional Tester.

    Thank you Jonas for jumping in and trying to assist Bill. I have granted you some Telerik Points in return.

    Kind regards,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top