Now you can do clicks_button 'foo_123' (passing button ID, not value)

This commit is contained in:
Gwyn Morfey 2008-07-07 15:57:52 +01:00
parent 20561b0c41
commit 9e673539a5
2 changed files with 8 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_id?(id)
@element["id"] =~ /^\W*#{Regexp.escape(id.to_s)}/i
end
def matches_caption?(value) def matches_caption?(value)
@element.innerHTML =~ /^\W*#{Regexp.escape(value.to_s)}/i @element.innerHTML =~ /^\W*#{Regexp.escape(value.to_s)}/i
end end

View File

@ -33,6 +33,10 @@ module Webrat
possible_buttons = fields_by_type([ButtonField]) possible_buttons = fields_by_type([ButtonField])
possible_buttons.each do |possible_button|
return possible_button if possible_button.matches_id?(value)
end
possible_buttons.each do |possible_button| possible_buttons.each do |possible_button|
return possible_button if possible_button.matches_value?(value) return possible_button if possible_button.matches_value?(value)
end end