简体   繁体   中英

Cucumber: How to compare table with colspan using table diff

Hi Im writing a cucumber feature to verify a table using capybara finder(not tableish). I followed dennisreimann tutorial and it works fine when there is no td colspan. It thrown IndexError when td has colspan. Has anyone managed to overcome this problem?I guess colspan breaks the 2d array structure that is passed into the diff! function. Any suggestion or hint would be much appreciated. Thanks

Example of table:

<table id="mytable">
  <tbody>
    <tr>
      <th>header</th>
      <td colspan="5">Value1</td>
      ...
    </tr>
  </tbody>
</table>

Code example from tutorial:

rows = find("table#mytable").all('tr')
table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
expected_table.diff!(table)

Ok So I found the confirmation that it's not working here . The assumption is the number of cell in each row is the same hence colspan breaks it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM