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
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
Test Studio Trainings
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.
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.
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
Test Studio Trainings
CellText is not coming as the listed properties. Even then I tried to use it but its not working.
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
Test Studio Trainings
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
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.
Cody
the Telerik team
Test Studio Trainings
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
Can anything be done on this issue today itself?
Regards,
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
Test Studio Trainings
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
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
Test Studio Trainings
I will be there at the scheduled time.
Regards,
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
Test Studio Trainings
Regards,
Tanu