Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How do i get the total number of rows and i have only the table id

View previous topic View next topic Go down

How do i get the total number of rows and i have only the table id

Post by sathya on 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


Last edited by sathya on Wed Apr 14, 2010 7:35 pm; edited 1 time in total (Reason for editing : added more)

sathya

Posts : 6
Join date : 2010-04-14

Back to top Go down

Re: How do i get the total number of rows and i have only the table id

Post by metman on 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.


Last edited by metman on Wed Apr 14, 2010 11:39 pm; edited 1 time in total (Reason for editing : HTML messed up the post)

metman
Amateur
Amateur

Posts : 58
Join date : 2010-04-02

Back to top Go down

Re: How do i get the total number of rows and i have only the table id

Post by sathya on 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();

sathya

Posts : 6
Join date : 2010-04-14

Back to top Go down

Re: How do i get the total number of rows and i have only the table id

Post by metman on Fri Apr 16, 2010 12:02 am

Good stuff. Smile You're welcome.

metman
Amateur
Amateur

Posts : 58
Join date : 2010-04-02

Back to top Go down

Re: How do i get the total number of rows and i have only the table id

Post by Sponsored content Today at 5:02 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum