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

@ -106,6 +106,10 @@ module Webrat
@element["value"] =~ /^\W*#{Regexp.escape(value.to_s)}/i @element["value"] =~ /^\W*#{Regexp.escape(value.to_s)}/i
end end
def matches_caption?(value)
@element.innerHTML =~ /^\W*#{Regexp.escape(value.to_s)}/i
end
def to_param def to_param
return nil if @value.nil? return nil if @value.nil?
super super

View File

@ -37,6 +37,11 @@ module Webrat
return possible_button if possible_button.matches_value?(value) return possible_button if possible_button.matches_value?(value)
end 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 nil
end end