Selenium - 如何计算表中的行数? [英] Selenium - How to count the number of rows in a table?

查看:224
本文介绍了Selenium - 如何计算表中的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个行数为n的表。我需要算一下,该怎么办?

I have a table with "n" number of rows. I need to count them, how to do?

示例: - 我的表格如下所示。

Example:- My table looks like the below entry.

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>


推荐答案

要将行数存储到表中,您可以使用 storeXpathCount

To store Number of rows into table you can use storeXpathCount

storeXpathCount | id=listBalances | NumberOfRows
echo  | ${NumberOfRows}

storeXpathCount将行计数存储到变量NumberOfRows
并且echo将返回计数。

storeXpathCount will store rows count into variable NumberOfRows And echo will return count.

这篇关于Selenium - 如何计算表中的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆