- sathya
- Posts : 6
Join date : 2010-04-14
How do i get the total number of rows and i have only the table id
Wed Apr 14, 2010 7:28 pm
HI ,
I am new to selenium coding ..and i am I am using Selenium with Java
When i click on a link it generates a table ( this table row is not constant but the col are constant, at time there can be 10 rows next time 25 rows etc)
How do i get the number of rows getting generated.? I only have the table name which will be constant
"xpath=//tablehMasterPlaceHolder_grvTitleListDistribution'"
In one of the post say
just use:
int rowCount = sel.getXpathCount([color=orange]XPathToTRElements).intValue();
What is XPathToTRElements? what do i have to pass ?
Thanks
Sathya
I am new to selenium coding ..and i am I am using Selenium with Java
When i click on a link it generates a table ( this table row is not constant but the col are constant, at time there can be 10 rows next time 25 rows etc)
How do i get the number of rows getting generated.? I only have the table name which will be constant
"xpath=//tablehMasterPlaceHolder_grvTitleListDistribution'"
In one of the post say
just use:
int rowCount = sel.getXpathCount([color=orange]XPathToTRElements).intValue();
What is XPathToTRElements? what do i have to pass ?
Thanks
Sathya
- metmanAmateur
- Posts : 58
Join date : 2010-04-02
Re: How do i get the total number of rows and i have only the table id
Wed Apr 14, 2010 11:38 pm
Assuming you are using a standard HTML table, the structure should be something like:
<table>
<tr>
<td></td><td></td>...
</tr>
...
</table>
So you should be using the getXpathCount() function on the equivalent of the Xpath "//table/tr" to count the rows. To count the number of cells per row, you would use something like "//table/tr[" + x + "]/td" where x id the row you are trying to count the cells of.
For you, provided that Xpath you listed actually works for the head of your table, you should be using something like sel.getXpathCount("//tablehMasterPlaceHolder_grvTitleListDistribution/tr"); That should get you what you are looking for.
<table>
<tr>
<td></td><td></td>...
</tr>
...
</table>
So you should be using the getXpathCount() function on the equivalent of the Xpath "//table/tr" to count the rows. To count the number of cells per row, you would use something like "//table/tr[" + x + "]/td" where x id the row you are trying to count the cells of.
For you, provided that Xpath you listed actually works for the head of your table, you should be using something like sel.getXpathCount("//tablehMasterPlaceHolder_grvTitleListDistribution/tr"); That should get you what you are looking for.
- sathya
- Posts : 6
Join date : 2010-04-14
Re: How do i get the total number of rows and i have only the table id
Thu Apr 15, 2010 2:17 pm
Hi Met,
Thank you for the quick reply ... its working
The syntax i used was :
int rowCount = selenium.getXpathCount("//TABLE[@id='ctl00_cphMasterPlaceHolder_grvTitleListDistribution']/TBODY/TR").intValue();
Thank you for the quick reply ... its working
The syntax i used was :
int rowCount = selenium.getXpathCount("//TABLE[@id='ctl00_cphMasterPlaceHolder_grvTitleListDistribution']/TBODY/TR").intValue();
- metmanAmateur
- Posts : 58
Join date : 2010-04-02
Re: How do i get the total number of rows and i have only the table id
Fri Apr 16, 2010 12:02 am
Good stuff. You're welcome.
Permissions in this forum:
You cannot reply to topics in this forum