Working With RadGridView

17 posts, 0 answers
  1. Austin
    Austin avatar
    4 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    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.
  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 22 Jun 2012 Link to this post

    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
  3. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 05 Feb 2013 Link to this post

    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.

  4. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 05 Feb 2013 Link to this post

    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.

  5. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 06 Feb 2013 Link to this post

    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
  6. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 19 Feb 2013 Link to this post

    Hi Plamen,

    CellText is not coming as the listed properties. Even then I tried to use it but its not working.
  7. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 19 Feb 2013 Link to this post

    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
  8. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 19 Feb 2013 Link to this post

    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
  9. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 19 Feb 2013 Link to this post

    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
  10. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 19 Feb 2013 Link to this post

    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
  11. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 19 Feb 2013 Link to this post

    Hi Cody/Plamen,

    Can anything be done on this issue today itself?

    Regards,
    Tanu
  12. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 20 Feb 2013 Link to this post

    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
  13. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 20 Feb 2013 Link to this post

    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
  14. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 20 Feb 2013 Link to this post

    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
  15. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 20 Feb 2013 Link to this post

    I am good with this time too. Thanks.

    I will be there at the scheduled time.

    Regards,
    Tanu
  16. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 20 Feb 2013 Link to this post

    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
  17. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 20 Feb 2013 Link to this post

    Thanks for the help Plamen. I really appreciate the quick response from your side.

    Regards,
    Tanu
Back to Top