watirfirewatirwatir-webdriver

Accessing table TH element using WATIR


I need to check if a certain column is displayed in the table. Each column has a TH header with an unique ID. What would the best way to check for the existence on a TH element in a table?

Here is an example of the table code.

<table id="attr-table">
  <thead>
    <tr>
      <th id="attr-action-col"><input type="checkbox" value="" class="attr-action-box" id="attr-action-col_box"></th>
      <th id="attr-name-col">Name<span class="ui-icon ui-icon-triangle-1-n"></span></th>
      <th id="attr-type-col"></th>
      <th id="attr-scope-col"></th>
      <th id="attr-value-col">English Value</th>
      <th id="attr-master-col">Master Value</th>
      <th id="attr-translation-col">T</th>
      <th id="attr-workflow-col">Status</th>
      <th id="attr-history-col">H</th>
    </tr>
  </thead>
<tbody>
....
</tbody></table>

TIA


Solution

  • Try th, it should work in watir-webdriver, if it does not work in other Watir gems:

    browser.th(:id, 'attr-translation-col').exists?