Watir:如何访问没有ID或NAME的表

Nin*_*Cat 4 watir firewatir

我正在尝试编写我的watir脚本来获取以下数据(表体标题和表格行数据,但我无法弄清楚如何访问表格.(一旦我得到它,休息是一块蛋糕).

任何人都可以提出一些可以帮助我访问桌子的东西吗?它没有名称或ID ......

<div id="income">
    <table class="tHe" cellspacing="0">
    <thead>
        <tr>
            <th id="companyLabel" class="tFirst" style="width:30%"> Quarter Ending  </th>
            <th id="201004" class="tFirst right">Apr&nbsp;10 </th>
            <th id="201001" class="tFirst right">Jan&nbsp;10 </th>
            <th id="200910" class="tFirst right">Oct&nbsp;09 </th>
            <th id="200907" class="tFirst right">Jul&nbsp;09 </th>
            <th id="200904" class="tFirst right">Apr&nbsp;09 </th>
        </tr>
    </thead>

    <tbody id="revenueBody">
    <tr>
        <td  class="indtr">Totals</dfn></td>
        <td class="right">2849.00</td>
        <td class="right">3177.00</td>
        <td class="right">5950.00</td>
        <td class="right">4451.00</td>
        <td class="right">3351.00</td>
    </tr>
    ...
Run Code Online (Sandbox Code Playgroud)

mar*_*arc 6

ie.table(:class =>'tHe')应该有效,如果没有其他表具有相同的类名

ie.table(:after?,ie.div(:id,'income'))应该有效,如果没有其他div为id'income'

或ie.table(:index => 0) - 您需要检查您的页面以查看表的正确索引值是什么.


Žel*_*pin 5

但等等,还有更多!:)

browser.div(:id => "income").table(:class => 'tHe')
browser.div(:id => "income").table(:index => 1)
...
Run Code Online (Sandbox Code Playgroud)