diff --git a/lib/webcat/driver/rack_test_driver.rb b/lib/webcat/driver/rack_test_driver.rb index 1a9bc6f8..55e4f2ab 100644 --- a/lib/webcat/driver/rack_test_driver.rb +++ b/lib/webcat/driver/rack_test_driver.rb @@ -37,7 +37,7 @@ class Webcat::Driver::RackTest def click if tag_name == 'a' session.visit(self[:href]) - elsif tag_name == 'input' and type == 'submit' + elsif tag_name == 'input' and %w(submit image).include?(type) Form.new(session, form).submit(self) end end diff --git a/lib/webcat/session.rb b/lib/webcat/session.rb index 010821cb..be8f4913 100644 --- a/lib/webcat/session.rb +++ b/lib/webcat/session.rb @@ -68,7 +68,12 @@ private end def find_button(locator) - find_element("//input[@type='submit'][@id='#{locator}']", "//input[@type='submit'][@value='#{locator}']") + find_element( + "//input[@type='submit'][@id='#{locator}']", + "//input[@type='submit'][@value='#{locator}']", + "//input[@type='image'][@id='#{locator}']", + "//input[@type='image'][@value='#{locator}']" + ) end def find_field(locator, *kinds) diff --git a/spec/session_spec.rb b/spec/session_spec.rb index 836ba731..06d93682 100644 --- a/spec/session_spec.rb +++ b/spec/session_spec.rb @@ -61,7 +61,7 @@ shared_examples_for "session" do @session.visit('/form') end - context "with value given" do + context "with value given on a submit button" do before do @session.click_button('awesome') @results = YAML.load(@session.body) @@ -118,7 +118,7 @@ shared_examples_for "session" do end end - context "with id given" do + context "with id given on a submit button" do it "should submit the associated form" do @session.click_button('awe123') results = YAML.load(@session.body) @@ -126,6 +126,22 @@ shared_examples_for "session" do end end + context "with value given on an image button" do + it "should submit the associated form" do + @session.click_button('okay') + results = YAML.load(@session.body) + results['first_name'].should == 'John' + end + end + + context "with id given on an image button" do + it "should submit the associated form" do + @session.click_button('okay556') + results = YAML.load(@session.body) + results['first_name'].should == 'John' + end + end + it "should follow redirects" do @session.click_button('Go FAR') @session.body.should include('You landed') diff --git a/spec/views/form.erb b/spec/views/form.erb index 077d0a52..c4794e03 100644 --- a/spec/views/form.erb +++ b/spec/views/form.erb @@ -84,6 +84,7 @@
+