Also find buttons by caption, if no value has been specified.
This commit is contained in:
parent
2855b4382f
commit
20561b0c41
@ -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?
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user