Java Selenium-如何计算表中的行数?

Java Selenium-如何计算表中的行数?,java,selenium,selenium-ide,Java,Selenium,Selenium Ide,我有一个行数为“n”的表。我需要数一数,怎么办 示例:-我的表格看起来像下面的条目 Type Balance Date received Date returned Payment method Amount General Default 10/01/2013 08:53:20 Cash $ 10.00 HTML of my table looks like this. <th> is

我有一个行数为“n”的表。我需要数一数,怎么办

示例:-我的表格看起来像下面的条目

Type        Balance Date received       Date returned   Payment method  Amount
General     Default 10/01/2013 08:53:20                 Cash            $ 10.00

HTML of my table looks like this. <th> is table title row and <td> are the entries done by the user. Everytime the user add the new entry, the count will increase and display a message "3 found for account 6478 ". where 3 is no of rows in the table.   
<fieldset>
<table id="listBalances" class="listTable" width="100%">
<thead>
<tr>
<th>Type</th>
<th>Balance</th>
<th>Date received</th>
<th>Date returned</th>
<th>Payment method</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<tr class="alt">
<td>General Deposit</td>
<td>Default for RTB</td>
<td>09/30/2013 06:58:41</td>
<td/>
<td>Cash</td>
<td>$ 5.00</td>
类型余额日期收到日期返回付款方式金额
一般默认值2013年1月10日08:53:20现金$10.00
我的表格的HTML如下所示。是表标题行,是由用户完成的条目。每次用户添加新条目时,计数将增加,并显示一条消息“为帐户6478找到3”。其中3是表中的行数。
类型
平衡
收到日期
返回日期
付款方式
数量
一般存款
RTB的默认值
09/30/2013 06:58:41
现金
$ 5.00

我建议如下:

1) 列出表中的元素(例如,如果需要计算行数,则使用适当的选择器选择任何行)

2) 然后创建web元素列表

List<WebElement> columnElments = driver.findElements(By.cssSelector("...blablabla..."));
int rowNumer = columnElmments.size();
List columnElments=driver.findElements(By.cssSelector(“…blablablabla…”));
int rowNumer=columnelments.size();
或者:

@FindBy
            (how = How.CSS, using = "blablablba")
List<WebElement> col;

int rowNumer =col.size();
@FindBy
(how=how.CSS,使用=“blablba”)
列表col;
int rowNumer=列大小();

希望您有了将行数存储到表中的想法,您可以使用
storeXpathCount

storeXpathCount | id=listBalances | NumberOfRows
echo  | ${NumberOfRows}
storeXpathCount将行数存储到变量NumberOfRows中
echo将返回count。

请提供一些表示您的表的代码,以便为您提供适当的选择器。还请澄清您使用的是哪种语言(Java)以及是否使用WebDriver(Selenium IDE?)。Java和Selenium IDE。不幸的是,如果他使用Selenium IDE,这也没用,您可以将该代码缩短为
int size=driver.findElements().size()