0

For a given table, I'd like to get the below

  1. total number of rows
  2. able to iterate over by row and column

using the Java Driver. I tried the option mentioned here with no luck.

Below is the HTML for table

<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>
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327

1 Answers1

0

I have implemented a similar function with sahi for ruby. To answer your questions:

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

  2. Loop through all the cells with: @browser.cell(table,rowIndex,colIndex).exists?()

You can find the corresponding api for sahi java

lippea
  • 31
  • 4