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

Problem in looping through each cells in the Silverlight Grid

4 Answers 123 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Selvakumar
Top achievements
Rank 1
Selvakumar asked on 17 Feb 2013, 08:56 AM
I am not able to get the row counts in the grid, I have tried the following code

    SilverlightApp app = ActiveBrowser.SilverlightApps()[0];  

    DataGrid grid = app.Find.ByName<DataGrid>("Root");  

    Log.WriteLine(T_Grid.RowElements.Count.ToString());

   
Got the following error,

 

Exception thrown executing coded step: '[SampleTest_CodedStep] : To Add WorkPapers'.InnerException:System.InvalidOperationException: Unable to find DataGrid rows container! Please override the .RowContainer property for custom DataGrid template. at ArtOfTest.WebAii.Silverlight.UI.DataGrid.get_RowElements() at TestProject1.SampleTest.SampleTest_CodedStep()

 

 

I have attached images which shows the table and also the DOM structure, Also let me know how to loop through each cells text block,Please reply as soon as possible

 

 

4 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 19 Feb 2013, 12:48 PM
Hello Selvakumar,

Thank you for trying Test Studio.

It seems the DataGrid is stored in the "grid" variable, so the last line of the code should be:

Log.WriteLine(grid.RowElements.Count.ToString());

Let me know if this helps.
 

Greetings,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Selvakumar
Top achievements
Rank 1
answered on 19 Feb 2013, 01:49 PM
Hi,

Thanks for the reply. This is the first time i am automating the Silverlight application. Actually that is not a DataGrid, its a ComponenetOne Grid control which contains other controls. I am not able to find DatGrid Xaml tag in the DOM. I am seeing DataGridRowPresenter and DataGridCellPresenter. Using these elements how can we loop through the textblock values. Please refer previous post attachments(images-1 and 2 DOM structure )

Grid does not contain definitions for RowElements
Thanks,
Selvakumar A
0
Selvakumar
Top achievements
Rank 1
answered on 20 Feb 2013, 11:52 AM
Hello,

I have got the solution on  my own as below,

SilverlightApp app = ActiveBrowser.SilverlightApps()[0];

FrameworkElement BodyDataGridPanel = app.Find.ByName<FrameworkElement>("DocumentsGrid");

IList<FrameworkElement> FileRoom_Table = BodyDataGridpanel.Children;

foreach (FrameworkElement Row_Element in FileRoom_Table)

{

    Log.WriteLine(Row_Element.TextBlockContent);

}



Thanks,
Selvakumar A

0
Boyan Boev
Telerik team
answered on 20 Feb 2013, 01:07 PM
Hi Selvakumar,

Glad to hear it!

If you have any further questions please do not hesitate to contact us. 


Kind regards,

Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Selvakumar
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Selvakumar
Top achievements
Rank 1
Share this question
or