Also find buttons by caption, if no value has been specified.

This commit is contained in:
Gwyn Morfey 2008-04-29 12:26:16 +01:00
parent 2855b4382f
commit 20561b0c41
2 changed files with 9 additions and 0 deletions

View File

@ -105,6 +105,10 @@ module Webrat
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?

View File

@ -37,6 +37,11 @@ module Webrat
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