Permalink
Browse files

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

  • Loading branch information...
1 parent 20561b0 commit 9e673539a5f8ed0f8aaec78dc8c5225612e8191e Gwyn Morfey committed Jul 7, 2008
Showing with 8 additions and 0 deletions.
  1. +4 −0 lib/webrat/field.rb
  2. +4 −0 lib/webrat/form.rb
View
4 lib/webrat/field.rb
@@ -106,6 +106,10 @@ def matches_value?(value)
@element["value"] =~ /^\W*#{Regexp.escape(value.to_s)}/i
end
+ def matches_id?(id)
+ @element["id"] =~ /^\W*#{Regexp.escape(id.to_s)}/i
+ end
+
def matches_caption?(value)
@element.innerHTML =~ /^\W*#{Regexp.escape(value.to_s)}/i
end
View
4 lib/webrat/form.rb
@@ -34,6 +34,10 @@ def find_button(value = nil)
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|
return possible_button if possible_button.matches_value?(value)
end

0 comments on commit 9e67353

Please sign in to comment.