Getting values from RadGridview(Silverlight) control for verification

3 posts, 1 answers
  1. Mariko
    Mariko avatar
    39 posts
    Member since:
    Jun 2011

    Posted 27 Jul 2011 Link to this post

    Hi Telerik team,

    I am trying to verify the contents of a RadGridView control. The rows from the grid are results of the Find function.
    For example I tried to search for 'firstname' the grid will give me:

    First Name Last Name Middle Name
    firstname1 lastname1 m
    firstname2 lastname2 m

    I used the "hover over highlighting = enabled" to get the RadGridview control properties and perform verification.
    I explored the "Quick Tasks" for getting the verification but I didn't find any.
    I also explored the "Build Verification" and also no luck.
    So I tried adding a custom step but when I write this code,
    Assert.IsFalse((ArtOfTest.Common.CompareUtils.StringCompare(Pages.CreateNewMeeting.SilverlightApp.FindResultsGridViewRadgridview.Rows.ToString(), "firstname", ArtOfTest.Common.StringCompareType.Contains) == false));
    I am encountering

    System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.WebAii.Controls.Xaml.RadGridView.get_GroupRows() at Telerik.WebAii.Controls.Xaml.RadGridView.get_Rows() at ...

    In Coded UI, we are using this approach where we highlight the whole table and get the "InnerText" property.
    It will give us this result:
    "First NameLast NameMiddle Namefirstname1lastname1mfirstname2lastname2m"
    So, for verification, we simply put something like this:
    Assert.IsTrue(Pages.CreateNewMeeting.SilverlightApp.FindResultsGridViewRadgridview.Rows.Contains("firstname"));

    Any thoughts on this?

    Thanks,
    Mariko

  2. Answer
    Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 28 Jul 2011 Link to this post

    Hi Mariko,

    We are aware of this exception and we are currently working on solving it. We will do our best to include a fix for it in near future. You can track the progress of this issue in our PITS system here .

    Meanwhile, we've developed a workaround for this issue. Here's how to change your code in order to make it work:

    // Locate the RadGridView
    RadGridView grid = Pages.CreateNewMeeting.SilverlightApp.FindResultsGridViewRadgridview
    // Get a list of all rows contained in it
    IList<GridViewRow> rows = grid.Find.AllByType<GridViewRow>();
      
    // Get the row
    GridViewRow row = rows[0];

    // Verify text contains "firstname" 
    Assert.IsTrue(row.Cells[0].Text.Contains("firstname"));
    I've attached a test that demonstrates this code in action.

    Let me know if it works!

    All the best,
    Plamen
    the Telerik team
    Check out the Test Studio roadmap to find out more about the new performance testing functionality coming in our R2 2011 release this September!

    Have you looked at the new Online User Guide for Telerik Test Studio?
  3. Mariko
    Mariko avatar
    39 posts
    Member since:
    Jun 2011

    Posted 01 Aug 2011 Link to this post

    Hi Plamen,

    I've revised your workaround a little bit and I got it to work now. :)
    Cells should be converted to TextBlock first before you can get the text it contains.

    RadGridView grid = Pages.MeetingFormPage.SilverlightApp.FindResultsGridViewRadgridview;
                  
                IList<GridViewRow> rows = grid.Find.AllByType<GridViewRow>();
                                         
                foreach (var i in rows)
                {
                    TextBlock block = i.Cells[1].Find.ByType<TextBlock>();
                    StringAssert.Contains(block.Text, "name");
                }

    Thanks!
    Mariko
Back to Top