0

对于给定的表,我想得到以下

  1. 总行数
  2. 能够按行和列迭代

使用Java 驱动程序。我尝试了这里提到的选项,但没有运气。

下面是表格的 HTML

<div id="hawkMessageCodeTable" class="ui-datatable ui-widget">
          <table>
            <thead>
              <tr>
                <th id="hawkMessageCodeTable:j_idt49" class="ui-state-default">
                  <div class="ui-dt-c">
                    <span>Code</span>
                  </div>
                </th>
                <th id="hawkMessageCodeTable:j_idt51" class="ui-state-default">
                  <div class="ui-dt-c">
                    <span>Message</span>
                  </div>
                </th>
              </tr>
            </thead>
            <tbody id="hawkMessageCodeTable_data" class="ui-datatable-data ui-widget-content">
              <tr data-ri="0" class="ui-widget-content ui-datatable-even">
                <td>
                  <div class="ui-dt-c">
                    9005
                  </div>
                </td>
                <td>
                  <div class="ui-dt-c">
                    Initial Fraud Alert on File
                  </div>
                </td>
              </tr>
              <tr data-ri="1" class="ui-widget-content ui-datatable-odd">
                <td>
                  <div class="ui-dt-c">
                    9003
                  </div>
                </td>
                <td>
                  <div class="ui-dt-c">
                    Security Alert or consumer statement on file relates to true name fraud or credit fraud
                  </div>
                </td>
              </tr>
              <tr data-ri="2" class="ui-widget-content ui-datatable-even">
                <td>
                  <div class="ui-dt-c">
                    2501
                  </div>
                </td>
                <td>
                  <div class="ui-dt-c">
                    Input/File (Current/Previous) Address Has Been Used (#) Times In The Last (30,60,90) Days On Different Inquiries
                  </div>
                </td>
              </tr>
              <tr data-ri="3" class="ui-widget-content ui-datatable-odd">
                <td>
                  <div class="ui-dt-c">
                    9004
                  </div>
                </td>
                <td>
                  <div class="ui-dt-c">
                    Active Duty Alert on File
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
4

1 回答 1

0

我已经用 sahi 为 ruby​​ 实现了一个类似的功能。要回答您的问题:

  1. rowLen = table.fetch("rows.length").to_i

  2. 循环遍历所有单元格:@browser.cell(table,rowIndex,colIndex).exists?()

可以找到sahi java对应的api

于 2013-04-17T05:03:02.857 回答