我有表格标题的代码:
<thead>
<tr class="ui-jqgrid-labels ui-sortable" role="rowheader" style="">
<th id="categories_formName" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 250px;">
<div id="jqgh_categories_formName" class="ui-jqgrid-sortable">Category Name</div>
</th>
<th id="categories_totalClicks" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 99px;">
<div id="jqgh_categories_totalClicks" class="ui-jqgrid-sortable">Clicks</div>
</th>
<th id="categories_avgCpc" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 99px;">
<div id="jqgh_categories_avgCpc" class="ui-jqgrid-sortable">Avg CPC($)</div>
</th>
<th id="categories_totalCost" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 99px;">
<div id="jqgh_categories_totalCost" class="ui-jqgrid-sortable">Total Cost($)</div>
</th>
<th id="categories_convertToSale" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr disabledHeader" style="width: 99px;">
<div id="jqgh_categories_convertToSale" class="ui-jqgrid-sortable">CTS(%)</div>
</th>
<th id="categories_totalOrders" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr disabledHeader" style="width: 99px;">
<div id="jqgh_categories_totalOrders" class="ui-jqgrid-sortable">Total Orders</div>
</th>
<th id="categories_totalSales" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr disabledHeader" style="width: 99px;">
<div id="jqgh_categories_totalSales" class="ui-jqgrid-sortable">Sales($)</div>
</th>
<th id="categories_costOfSale" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr disabledHeader" style="width: 96px;">
<div id="jqgh_categories_costOfSale" class="ui-jqgrid-sortable">COS(%)</div>
</th>
</tr>
并且需要找到有多少个标签具有“disabledHeader”类或至少获取特定类(由id寻址)。
当我做:
cl = b.th(:xpath, '//th[@id="categories_convertToSale"]')
cl.exist?
=> true
cl.inspect
=> "#<Watir::TableHeaderCell:0x..f9b976cc1015b866a located=true selector={:xpath=>\"//th[@id=\\\"categories_convertToSale\\\"]\", :tag_name=>\"th\"}>"
cl.class
=> Watir::TableHeaderCell
cl[@class]
或cl(:class)
返回错误。
b.element(:class, "disabledHeader").size
返回方法丢失错误。
如何解决th-s
这个类的所有问题?