title: How to get a HTML table row with Capybara
body: <p>I am trying to scan rows in a HTML table using partial href xpath and perform further tests with that row's other column values. </p>
  
  <pre><code>  &lt;div id = "blah"&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;a href="afile?key=HONDA"&gt;link&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;29 33 485&lt;/td&gt;
        &lt;td&gt;45.2934,00 EUR&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;a href="afile?key=HONDA"&gt;link&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;22 93 485&lt;/td&gt;
        &lt;td&gt;38.336.934,123 EUR&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;a href="afile?key=something_else"&gt;link&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;394 27 3844&lt;/td&gt;
        &lt;td&gt;3.485,2839 EUR&lt;/td&gt;
      &lt;/tr&gt;    
    &lt;/table&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>In cucumber-jvm step definition, I performed this much easily like below (I am more comfortable using Ruby)</p>
  
  <pre><code>@Given("^if there are...$")
  public void if_there_are...() throws Throwable {
              ...
              ...
             baseTable = driver.findElement(By.id("blah"));
             tblRows = baseTable.findElements(By.tagName("tr"));
  
          for(WebElement row : tblRows) {                                                 
              if (row.findElements(By.xpath(".//a[contains(@href,'key=HONDA')]")).size() &gt; 0) {
                  List&lt;WebElement&gt; col = row.findElements(By.tagName("td")); 
                  tblData dummyThing = new tblData();
                  dummyThing.col1 = col.get(0).getText();
                  dummyThing.col2 = col.get(1).getText();
                  dummyThing.col3 = col.get(2).getText();
                  dummyThing.col4 = col.get(3).getText();
                  dummyThings.add(dummyThing);
              }
          }
  </code></pre>
  
  <p>I am clueless here</p>
  
  <pre><code>page.find('#blah').all('tr').each { |row|
    # if row matches xpath then grab that complete row
    # so that other column values can be verified
    # I am clueless from here
    row.find('td').each do { |c|
  
    }
    page.find('#blah').all('tr').find(:xpath, ".//a[contains(@href,'key=HONDA')]").each { |r|
      #we got the row that matches xpath, let us do something
    }
  }
  </code></pre>