rubywatirfirewatir

Get value of a second table cell with unique text in first cell of the row with Watir


I want to get the value in the second cell of a row of a table, where a unique value is in the first cell. The value of the second cell keeps on changing.

<table class="mm-table" cellspacing="0" cellpadding="3" border="0">
  <tr class="trhover" onclick="location.href='stock.php?id=RI&p=wtch';">
    <td align="left" rowspan="1" class="tdwidth35per paddingleft4px">
      <a shape="rect" href="stock.php?id=RI&p=wtch"> Reliance </a></td>
    <td align="right" rowspan="1" class="tdwidth35per"> **951.35** </td>
    <td align="right" rowspan="1" class="tdwidth30per"><font color="#008000">0.60</font></td>
</tr>

Above is the table. There are other tables with the same name. I want to access the second cell which contains the text "951.35"


Solution

  • Try something like this:

    browser.table(:class => "mm-table").cell(:class => "tdwidth35per")