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

Table Related Query

1 Answer 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vaibhav
Top achievements
Rank 1
Vaibhav asked on 01 Dec 2011, 07:37 PM
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...    

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 07 Dec 2011, 10:25 AM
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
Tags
General Discussions
Asked by
Vaibhav
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or