title: How do I click on a specific button using cucumber/webrat when the name of the button starts with the same word?
body: <p>I have the following html with multiple inputs:</p>
  
  <pre><code>&lt;input type="submit" value="Save and close" name="commit"/&gt;
  &lt;input type="submit" value="Save" name="commit"/&gt;
  </code></pre>
  
  <p>and would like to use cucumber to test clicking on the "Save" button. However, when I do this in a cucumber test:</p>
  
  <pre><code>When I press "Save"
  </code></pre>
  
  <p>it clicks on the "Save and close" button, since it appears before the "Save" button.</p>
  
  <p>Looking at the webrat source for finding the button:</p>
  
  <pre><code>def button_element
    button_elements.detect do |element|
      @value.nil?             ||
      matches_id?(element)    ||
      matches_value?(element) ||
      matches_html?(element)  ||
      matches_alt?(element)
    end
  end
  
  ...
  
  def matches_value?(element)
    element["value"] =~ /^\W*#{Regexp.escape(@value.to_s)}/i
  end
  
  ...
  </code></pre>
  
  <p>it seems like webrat takes the first match, and only matches from the beginning of the content.</p>
  
  <p>Is there any way of making an exact match, so cucumber finds "Save" and disregards "Save and close"?</p>