3

「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>
4

2 に答える 2

-3

次のことをお勧めします。

1)テーブルの要素のリストを作成します(たとえば、行数をカウントする必要がある場合は、適切なセレクターを使用して任意の行を選択します)。

2) 次に、Web 要素のリストを作成します

List<WebElement> columnElments = driver.findElements(By.cssSelector("...blablabla..."));
int rowNumer = columnElmments.size();

または次のいずれか:

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

int rowNumer =col.size();

あなたがアイデアを得たことを願っています

于 2013-10-03T09:36:03.653 に答える