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

Can't find RadGrid on page

5 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 15 Aug 2014, 07:23 PM
Hi,
I am using Test Studio Visual Studio plugin to create test cases. I am trying to find a way to get the items in RadGrid on page and iterate over each row to validate the data in each row / column is correct. While using the record option I can get the value for one cell at a time, but I cannot find a way to get the entire item collection.
Can you show me a way to get all items in grid and loop over the rows?
I have attached a simple demo of my site for your reference.

Note: I was unable to include Telerik.Web.UI.dll in demo site zip due to size constraints.

Thanks!

5 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 20 Aug 2014, 04:13 PM
Hi Matt,

The only way to get all the items of a grid is through code like this:
GridTableView myRadGrid = ActiveBrowser.Find.ById<GridTableView>("RadGrid1");
IList<HtmlTableRow> rows = myRadGrid.AllRows;



Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Matt
Top achievements
Rank 1
answered on 25 Aug 2014, 10:00 PM
That does not work. I tried using the find by id method using the id of the radgrid and the id of the grid as it is displayed in DOM Explorer. Both ways came back as null. Can you tell me what I need to pass as the id since nothing I have tried is working. 
I attached a sample project of how our website is setup for your reference if needed on my original post.

Thanks
0
Cody
Telerik team
answered on 27 Aug 2014, 01:22 AM
Hi Matt,

Unfortunately there was no sample project attached to your message. The code below works against this demo page:
GridTableView myRadGrid = ActiveBrowser.Find.ById<GridTableView>("ctl00_ContentPlaceHolder1_RadGrid1_ctl00");
IList<HtmlTableRow> rows = myRadGrid.BodyRows;
Log.WriteLine("Number of rows: " + rows.Count.ToString());

The HTML for this RadGrid looks like this:
<div tabindex="0" class="RadGrid RadGrid_WebBlue rgMultiHeader" id="ctl00_ContentPlaceHolder1_RadGrid1">
    <table class="rgMasterTable" id="ctl00_ContentPlaceHolder1_RadGrid1_ctl00" style="width: 100%; table-layout: auto; empty-cells: show;">

Note I'm using the ID of the <table> element.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Matt
Top achievements
Rank 1
answered on 28 Aug 2014, 09:28 PM
Hi Cody,
I'm still having problems getting the find by id method to return the grid rows. Which table element should I use?
Here is a sample of my html page for your reference.

0
Cody
Telerik team
answered on 02 Sep 2014, 04:33 PM
Hi Matt,

This line represents the RadGrid:
<div id="ctl00_MainContent_UserControlswucConfiguration_rgConfigruation" class="RadGrid RadGrid_Sitefinity" enablevirtualscrollpaging="false" savescrollposition="True" style="width: 1170px; height: 550px;" tabindex="0" usestaticheaders="true">

The way you can tell is looking for a <div> element in which the class contains "RadGrid" in it. Thus you should be using the id "ctl00_MainContent_UserControlswucConfiguration_rgConfigruation".

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Matt
Top achievements
Rank 1
Answers by
Cody
Telerik team
Matt
Top achievements
Rank 1
Share this question
or