Skip to content

Commit

Permalink
Also find buttons by caption, if no value has been specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwyn Morfey committed Apr 29, 2008
1 parent 2855b43 commit 20561b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/webrat/field.rb
Expand Up @@ -105,6 +105,10 @@ class ButtonField < Field
def matches_value?(value)
@element["value"] =~ /^\W*#{Regexp.escape(value.to_s)}/i
end

def matches_caption?(value)
@element.innerHTML =~ /^\W*#{Regexp.escape(value.to_s)}/i
end

def to_param
return nil if @value.nil?
Expand Down
5 changes: 5 additions & 0 deletions lib/webrat/form.rb
Expand Up @@ -37,6 +37,11 @@ def find_button(value = nil)
return possible_button if possible_button.matches_value?(value)
end

#If nothing matched on value, try by name.
possible_buttons.each do |possible_button|
return possible_button if possible_button.matches_caption?(value)
end

nil
end

Expand Down

0 comments on commit 20561b0

Please sign in to comment.