From b4d85cb50bf940946454f466abf72fb947d5ff33 Mon Sep 17 00:00:00 2001 From: Lena Date: Wed, 7 Jan 2009 12:27:47 +0100 Subject: [PATCH] Added recognition of input tags with type button, which are generated by the Rails submit_to_remote helper --- lib/webrat/core/elements/field.rb | 3 ++- spec/public/click_button_spec.rb | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/webrat/core/elements/field.rb b/lib/webrat/core/elements/field.rb index 8f16ba3..5b58140 100644 --- a/lib/webrat/core/elements/field.rb +++ b/lib/webrat/core/elements/field.rb @@ -45,6 +45,7 @@ module Webrat when "file" then FileField when "reset" then ResetField when "submit" then ButtonField + when "button" then ButtonField when "image" then ButtonField else TextField end @@ -168,7 +169,7 @@ module Webrat class ButtonField < Field #:nodoc: def self.xpath_search - [".//button", ".//input[@type = 'submit']", ".//input[@type = 'image']"] + [".//button", ".//input[@type = 'submit']", ".//input[@type = 'button']", ".//input[@type = 'image']"] end def to_param diff --git a/spec/public/click_button_spec.rb b/spec/public/click_button_spec.rb index ed21488..f7086b2 100644 --- a/spec/public/click_button_spec.rb +++ b/spec/public/click_button_spec.rb @@ -425,7 +425,7 @@ describe "click_button" do webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""}) click_button end - + it "should recognize button tags" do with_html <<-HTML @@ -439,6 +439,18 @@ describe "click_button" do click_button end + it "should recognize input tags with the type button" do + with_html <<-HTML + +
+ +
+ + HTML + webrat_session.should_receive(:get) + click_button + end + it "should recognize image button tags" do with_html <<-HTML