I have the following html with multiple inputs:
<input type="submit" value="Save and close" name="commit"/>
<input type="submit" value="Save" name="commit"/>
and would like to use cucumber to test clicking on the "Save" button. However, when I do this in a cucumber test:
When I press "Save"
it clicks on the "Save and close" button, since it appears before the "Save" button.
Looking at the webrat source for finding the button:
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
...
it seems like webrat takes the first match, and only matches from the beginning of the content.
Is there any way of making an exact match, so cucumber finds "Save" and disregards "Save and close"?