title: Select from last matching select menu in Capybara 1.1.2
body: <p>I'm working with a Hobo app using the <code>input_many</code> tag to handle a many-to-many relationship on a form. This puts + and - buttons on the page, and the + adds a new <code>select</code> tag for picking the model on the other side of the relationship. This means that there can be an arbitrary number of <code>select</code> menus with very similar characteristics, distinguished only by an array index, like this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;select class="input belongs_to data_set_graph" name="graph_pane[data_set_graphs][0][data_set_id]"&gt;
  [...options...]
  &lt;/select&gt;
  &lt;select class="input belongs_to data_set_graph" name="graph_pane[data_set_graphs][1][data_set_id]"&gt;
  [...options...]
  &lt;/select&gt;
  </code></pre>
  
  <p>N.B. the join of GraphPanes and DataSets is polymorphic (there are many kinds of GraphPanes) so the actual CSS class name varies according to the kind of pane - it could be <code>data_set_a_graph_pane_data_set</code> or <code>data_set_b_graph_pane_data_set</code>.</p>
  
  <p>We've been using Capybara 1.1.2 to test this. As long as we're only associating one DataSet with a GraphPane, we've been able to select them with a step definition like this:</p>
  
  <pre class="lang-ruby prettyprint-override"><code>included_defs.each do |data_set_name|
    click_button "+"
    select_node = find(:css, '.input-many-item select') # There may be more than one of these?
    select_node.find(:xpath, XPath::HTML.option(data_set_name), :message =&gt; "cannot select option with text '#{data_set_name}'").select_option
  end
  </code></pre>
  
  <p>However, now we need to associate two DataSets with a GraphPane, and the <code>find(:css, '.input-many-item select')</code> fails because there are two matching nodes.</p>
  
  <p>It seems to me that if I could just always pick the last one, this would work, but I can't figure out how to do this with Capybara's selectors. (I think part of the problem is that it's not clear to me, in most of the examples I find, whether they refer to the 1.x DSL or the 2.x series.)</p>
  
  <p>Ideas for sorting this out elegantly are welcome.</p>