[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Row count of table

Vani Kulkarni

8/7/2007 1:56:00 PM

Hello all,
I am stuck up in finding the row count of a table in a HTML page through
Watir script. I am using row_count() function to find the number of rows
in the table. Its returning me incorrect number of rows in the table. I
tried accessing the table through xpath, since I did not have attribute
associated with the table. Following is the HTML of the table [obtained
through IE developer bar] whose row count I need:

<TD id="ctl00_ContentPlaceHolder1_dtGridEmployees_dom"
style="VERTICAL-ALIGN: top; HEIGHT: 47px">
<TABLE style="WIDTH: 100%" cellSpacing="0" cellPadding="0" border="0">
<TBODY>
<TR id="ctl00_ContentPlaceHolder1_dtGridEmployees_top_head">
</TR>
<TR class="Row"
id="ctl00_ContentPlaceHolder1_dtGridEmployees_row_0"
onmouseover="ctl00_ContentPlaceHolder1_dtGridEmployees.OverHandler(event,this,0)"
onmouseout="ctl00_ContentPlaceHolder1_dtGridEmployees.OutHandler(event,this,0)"
styleCached>
</TR>
</TBODY>
</TABLE>
</TD>

The row_count() for the table inside the <TD> gives as 9, instead of 2.
I am using the following xpath :
$ie.table(:xpath,
"//td[@id='ctl00_ContentPlaceHolder1_dtGridEmployees_dom']/table").row_count()

Am I going wrong anywhere? Please let me know.

Thanks,
Vani
--
Posted via http://www.ruby-....

1 Answer

Paul Rogers

8/7/2007 4:56:00 PM

0

On Aug 7, 7:56 am, Vani Kulkarni <vani.v.kulka...@gmail.com> wrote:
> Hello all,
> I am stuck up in finding the row count of a table in a HTML page through
> Watir script. I am using row_count() function to find the number of rows
> in the table. Its returning me incorrect number of rows in the table. I
> tried accessing the table through xpath, since I did not have attribute
> associated with the table. Following is the HTML of the table [obtained
> through IE developer bar] whose row count I need:
>
> <TD id="ctl00_ContentPlaceHolder1_dtGridEmployees_dom"
> style="VERTICAL-ALIGN: top; HEIGHT: 47px">
> <TABLE style="WIDTH: 100%" cellSpacing="0" cellPadding="0" border="0">
> <TBODY>
> <TR id="ctl00_ContentPlaceHolder1_dtGridEmployees_top_head">
> </TR>
> <TR class="Row"
> id="ctl00_ContentPlaceHolder1_dtGridEmployees_row_0"
> onmouseover="ctl00_ContentPlaceHolder1_dtGridEmployees.OverHandler(event,this,0)"
> onmouseout="ctl00_ContentPlaceHolder1_dtGridEmployees.OutHandler(event,this,0)"
> styleCached>
> </TR>
> </TBODY>
> </TABLE>
> </TD>
>
> The row_count() for the table inside the <TD> gives as 9, instead of 2.
> I am using the following xpath :
> $ie.table(:xpath,
> "//td[@id='ctl00_ContentPlaceHolder1_dtGridEmployees_dom']/table").row_count()
>
> Am I going wrong anywhere? Please let me know.
>
> Thanks,
> Vani
> --
> Posted viahttp://www.ruby-....

you should post this to the watir group ( http://groups.google.ca/group/watir-gener...
)
I think the problem you are having is because of nested tables

Paul