Table Related Query

2 posts, 0 answers
  1. Vaibhav
    Vaibhav avatar
    8 posts
    Member since:
    Nov 2011

    Posted 01 Dec 2011 Link to this post

    I want to select the last row of a table. The table is populated according to options given by the user and based on the data in the database (which keeps changing as there are updations and deletions going on every now and then). So, the number of rows will differ every time my test case is executed. How do I set up my test case so that every time the test is executed the last row in the table is selected.
    I have attached a screenshot of what the table looks like. So, in this table I would want to select the row wherein the SRV# is 1312184 as that is the last row.. But next time when somebody runs the test case, this row might not be the last row and the size of the table might also change. For example, this table has 4 rows but next time the test case is run the table may have 10 rows or just 2 rows. I hope you catch my drift...
    Also, I tried to extract the values of the SRV# from previous steps (as the SRV # are unique) and use them to select the row. But if you see the picture every SRV# has a dotted line which means they are linked to another page. Now, I don't want to click exactly on the number as I don't want to open that link. If one clicks anywhere in the row that row gets selected and that is what I want to do.

    Any suggestions...    
  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 07 Dec 2011 Link to this post

    Hi Vaibhav,

    I'm sorry for the delay getting back to you on this.

    You can easily select the row you want by using code similar to this.
    HtmlTable myTable = Pages.ASPNETGridDemo.RadGrid1OrdersGridTable;
     
    // Locate the row using the text content         
    HtmlTableRow row = myTable.Find.ByContent<HtmlTableCell>(Data["ExtractedSRV#Variable"].ToString()).Parent<HtmlTableRow>();
     
    //Locate the second sell in the row
    HtmlTableCell cell = row.Cells[2];
     
    //Click on the cell
    cell.Click();

    In this way, you will find the row that contains the extracted SRV# value and then click on the second cell to select the row.

    Hope this helps!

    Greetings,
    Plamen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top