title: How can I find a certain element that comes right after another element with Capybara?
body: <p>I am trying to use learn <em>Capybara</em> for a scraping task I have. I have heretofore only used it for testing. There are a million things I want to learn, but at the very basic part of it I want to know how to find a certain element that is a sibling and comes <em>after</em> another element that I am able to find?</p>
  
  <p>Take a page like this:  </p>
  
  <pre><code>&lt;body&gt;
    &lt;h3&gt;Name1&lt;/h3&gt;
    &lt;table&gt;
      ...
    &lt;/table&gt;
    &lt;h3&gt;Name2&lt;/h3&gt;
    &lt;table&gt;
      ...
    &lt;/table&gt;
    &lt;h3&gt;Name3&lt;/h3&gt;
    &lt;table&gt;
      ...
    &lt;/table&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I want to return the <code>&lt;table&gt;</code> element that comes after the <code>&lt;h3&gt;</code> element having text <em>Name2</em>.</p>
  
  <p>I know how to loop through elements with <code>all</code>, and I know how to use <code>first</code> instead of <code>find</code>, but I don't know how to "Find the first element <em>X</em> following specific element <em>Y</em>".</p>