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

Working With RadGridView

16 Answers 130 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 19 Jun 2012, 07:53 PM
I have been searching the internet and the only information on RadGridView's i can find with Test Studio are those that pertain to Silverlight.

I have a problem with a potentially pretty simple solution I just cant find a KB on it.

I have a RadGridView in my web app

In Code i need to bind that RadGridView, Iterate through the rows, Find the row where the third column cell equals the variable I have saved in my DataBinding ie
orderid.Equals(row.Cells[2].Text)


Then the column that has that orderid, I need to perform a click the first cell.

Problems I am running into is binding the RadGridView, the ID for it is "WideContent_DashboardGrid" 

Any help is much appreciated.

16 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 22 Jun 2012, 12:56 PM
Hi Austin,

Here's a sample code against this Telerik RadGrid demo site:
RadGrid grid = ActiveBrowser.Find.ById<RadGrid>("RadGrid1");
grid.ScrollToVisible();
foreach (GridDataItem row in grid.MasterTable.DataItems)
{
    if (row.DataCells[2].Text == Data["Col1"].ToString())
    {
        row.DataCells[0].MouseClick();
    }
}

This code will search for a row where the third cell equals a value from the database('Col1'). When the row is found it will click on the first cell. The demo project is attached.

Please let me know if you need further assistance on this.

Greetings,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tanu
Top achievements
Rank 1
answered on 05 Feb 2013, 02:35 PM
Hi Plamen,

This is Tanu again. After your help I reached the next level in my application. Now I encountered a radgrid and search through net and found this reply of yours. I added the code given by you and got the error

c:\Users\Tanu\Documents\Test Studio Projects\TestProject2\WebTest.tstest.cs: Line 83: (CS1061) 'Telerik.WebAii.Controls.Html.GridDataCell' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'Telerik.WebAii.Controls.Html.GridDataCell' could be found (are you missing a using directive or an assembly reference?)

Code is: RadGrid grid = ActiveBrowser.Find.ById<RadGrid>("RadGrid1");
grid.ScrollToVisible();
foreach (GridDataItem row in grid.MasterTable.DataItems)
{
    if (row.DataCells[2].Text == Data["Col1"].ToString())
    {
        row.DataCells[0].MouseClick();
    }
}

I guess RadGrid1 is the name of the grid and we need to add it to the Project elements. Am I right?

Though i dont want to do what exactly has been mention in this thread. I want to search an item in the RadGrid and click that. So there is only a little bit of difference. Thats why posting my query here only.

0
Tanu
Top achievements
Rank 1
answered on 05 Feb 2013, 06:31 PM

RadGrid grid = Pages.EndpointPULSE.FrameContentiframe.RadGridSections;

foreach(GridDataItem row in grid.MasterTable.DataItems)

 {

 if(row.DataCells[0].ToString() == Data["Col1"].ToString())

 {

row.DataCells[0].MouseClick();  

}

}

I re-wrote the code as written above. i am not getting any error but click is not working either.

Also i didn't find "MouseClick" event while looking for the event in the list.

0
Plamen
Telerik team
answered on 06 Feb 2013, 03:09 PM
Hello Tanu,

In order to make this to work you need to use the "CellText" property of the cell. Please try it like this:

RadGrid grid = Pages.EndpointPULSE.FrameContentiframe.RadGridSections;
 
foreach(GridDataItem row in grid.MasterTable.DataItems)
{
   if(row.DataCells[0].CellText == Data["Col1"].ToString())
   {
      row.DataCells[0].MouseClick(); 
   }
}

Hope this help!

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tanu
Top achievements
Rank 1
answered on 19 Feb 2013, 08:01 AM
Hi Plamen,

CellText is not coming as the listed properties. Even then I tried to use it but its not working.
0
Plamen
Telerik team
answered on 19 Feb 2013, 04:01 PM
Hi Tanu,

It really depends on how the RadGrid is implemented. Please try using the InnerText or TextContent properties instead. You can also log the result from all of them and see which one will give you the desired text.
RadGrid grid = Pages.EndpointPULSE.FrameContentiframe.RadGridSections;
foreach(GridDataItem row in grid.MasterTable.DataItems)            
{              
    Log.WriteLine(row.DataCells[0].InnerText);              
    Log.WriteLine(row.DataCells[0].TextContent);
    Log.WriteLine(row.DataCells[0].CellText);                      
}


All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tanu
Top achievements
Rank 1
answered on 19 Feb 2013, 04:23 PM
Hi Plamen,

None of them is working. Also it is not possible to provide the fiddlercap trace as my client still don't have confidence in that till that the time we purchase the tool. Also tommorrow is the last day of my trial and it is quite urgent to be solved. Please help

Thanks.

Regards,
Tanu
0
Cody
Telerik team
answered on 19 Feb 2013, 04:45 PM
Hi Tanu,

Until we can reproduce the problem ourselves, we can only make guesses what is causing the problem and how to fix it. To reproduce the problem we must have either direct access to your application being tested or the fiddler trace we previously asked for. Until then we can only offer blind guesses how to fix this.

What is your time zone? Since it is critical to get this resolved ASAP, I can do a GoToMeeeting with you today. I am located in Austin, TX which is GMT -6. Or Plamen can do a GoToMeeting with you tomorrow. He's in Sofia, Bulgaria which is much closer to India timezone than I am.

Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tanu
Top achievements
Rank 1
answered on 19 Feb 2013, 05:35 PM
Thanks Cody.

I am ok with tommorrow also. So Plamen can do that for me and that will be great. I am ok with anytime between 9 AM(IST) till 9 PM(IST). So you can keep anytime which suits you.
Also if you want to do it then kindly make it before 12midnight today.

Thanks again.


Regards,
Tanu
0
Tanu
Top achievements
Rank 1
answered on 20 Feb 2013, 05:53 AM
Hi Cody/Plamen,

Can anything be done on this issue today itself?

Regards,
Tanu
0
Plamen
Telerik team
answered on 20 Feb 2013, 08:36 AM
Hi Tanu,

I sent you a meeting request for today 4:00 PM(IST). Feel free to update the time if you feel it's necessary. 

Kind regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tanu
Top achievements
Rank 1
answered on 20 Feb 2013, 08:42 AM
Hello Plamen,

thanks for help. I saw the invite but it is for 5 to 6PM(IST). So can you confirm is it 4PM or 5PM? I am good with both. 4PM would be better though.

Regards,
Tanu
0
Plamen
Telerik team
answered on 20 Feb 2013, 08:49 AM
Hi Tanu,

I am sorry, I haven't calculated the time zone difference correctly. The meeting is scheduled for 5PM, IST. Unfortunately we have another meeting before that.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tanu
Top achievements
Rank 1
answered on 20 Feb 2013, 09:02 AM
I am good with this time too. Thanks.

I will be there at the scheduled time.

Regards,
Tanu
0
Plamen
Telerik team
answered on 20 Feb 2013, 12:04 PM
Hi Tanu,

Just to document the outcome of our meeting today:

We examined the DOM tree and it turned out that the text you are looking for is actually in the second cell, not in the first one. Your test now works as expected after we changed the index for that cell i.e. - row.DataCells[1].CellText.

Thanks for your time.

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tanu
Top achievements
Rank 1
answered on 20 Feb 2013, 12:31 PM
Thanks for the help Plamen. I really appreciate the quick response from your side.

Regards,
Tanu
Tags
General Discussions
Asked by
Austin
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Tanu
Top achievements
Rank 1
Cody
Telerik team
Share this question
or