Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
sathya
Posts : 6
Join date : 2010-04-14

How do i get the total number of rows and i have only the table id Empty 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


Last edited by sathya on Wed Apr 14, 2010 7:35 pm; edited 1 time in total (Reason for editing : added more)
avatar
metman
Amateur
Amateur
Posts : 58
Join date : 2010-04-02

How do i get the total number of rows and i have only the table id Empty 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.


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)
avatar
sathya
Posts : 6
Join date : 2010-04-14

How do i get the total number of rows and i have only the table id Empty 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 How do i get the total number of rows and i have only the table id Icon_smile

The syntax i used was :
int rowCount = selenium.getXpathCount("//TABLE[@id='ctl00_cphMasterPlaceHolder_grvTitleListDistribution']/TBODY/TR").intValue();
avatar
metman
Amateur
Amateur
Posts : 58
Join date : 2010-04-02

How do i get the total number of rows and i have only the table id Empty 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. Smile You're welcome.
Sponsored content

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

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