Problem in looping through each cells in the Silverlight Grid

5 posts, 0 answers
  1. Selvakumar
    Selvakumar avatar
    3 posts
    Member since:
    Feb 2013

    Posted 17 Feb 2013 Link to this post

    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

     

     

  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 19 Feb 2013 Link to this post

    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
  3. Selvakumar
    Selvakumar avatar
    3 posts
    Member since:
    Feb 2013

    Posted 19 Feb 2013 Link to this post

    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
  4. Selvakumar
    Selvakumar avatar
    3 posts
    Member since:
    Feb 2013

    Posted 20 Feb 2013 Link to this post

    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

  5. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 20 Feb 2013 Link to this post

    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
Back to Top