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

Getting values from RadGridview(Silverlight) control for verification

2 Answers 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mariko
Top achievements
Rank 1
Mariko asked on 27 Jul 2011, 08:49 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 28 Jul 2011, 03:24 PM
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?
0
Mariko
Top achievements
Rank 1
answered on 01 Aug 2011, 08:16 AM

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
Tags
General Discussions
Asked by
Mariko
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Mariko
Top achievements
Rank 1
Share this question
or