sahi和桌子操作

时间:2013-03-20 23:15:44

标签: sahi twist

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

  1. 总行数
  2. 能够按行和列进行迭代
  3. 使用Java Driver。我尝试了mentioned here选项没有运气。

    以下是表格的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>
    

1 个答案:

答案 0 :(得分:0)

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

  1. rowLen = table.fetch(“rows.length”)。to_i

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

  3. 你可以找到sahi java的相应api