diff --git a/lib/webrat/core/elements/field.rb b/lib/webrat/core/elements/field.rb
index 8f16ba3..8e3c1c6 100644
--- a/lib/webrat/core/elements/field.rb
+++ b/lib/webrat/core/elements/field.rb
@@ -180,10 +180,10 @@ module Webrat
nil
end
- def click
+ def click(opts = {})
raise_error_if_disabled
set(Webrat::XML.attribute(@element, "value")) unless Webrat::XML.attribute(@element, "name").blank?
- form.submit
+ form.submit(opts)
end
end
diff --git a/lib/webrat/core/elements/form.rb b/lib/webrat/core/elements/form.rb
index 81859da..0897685 100644
--- a/lib/webrat/core/elements/form.rb
+++ b/lib/webrat/core/elements/form.rb
@@ -16,8 +16,8 @@ module Webrat
@fields ||= Field.load_all(@session, @element)
end
- def submit
- @session.request_page(form_action, form_method, params)
+ def submit(opts = {})
+ @session.request_page(form_action, form_method, params(opts))
end
def field_named(name, *field_types)
@@ -38,8 +38,8 @@ module Webrat
end
end
- def params
- all_params = {}
+ def params(opts = {})
+ all_params = opts.dup
fields.each do |field|
next if field.to_param.nil?
diff --git a/lib/webrat/core/scope.rb b/lib/webrat/core/scope.rb
index df92c5a..4553e27 100644
--- a/lib/webrat/core/scope.rb
+++ b/lib/webrat/core/scope.rb
@@ -253,8 +253,8 @@ module Webrat
#
# The URL and HTTP method for the form submission are automatically read from the
# action and method attributes of the element.
- def click_button(value = nil)
- find_button(value).click
+ def click_button(value = nil, opts = {})
+ find_button(value).click(opts)
end
webrat_deprecate :clicks_button, :click_button
diff --git a/spec/integration/rails/app/controllers/webrat_controller.rb b/spec/integration/rails/app/controllers/webrat_controller.rb
index b67e6b8..a870a0a 100644
--- a/spec/integration/rails/app/controllers/webrat_controller.rb
+++ b/spec/integration/rails/app/controllers/webrat_controller.rb
@@ -15,4 +15,11 @@ class WebratController < ApplicationController
redirect_to "http://google.com"
end
-end
\ No newline at end of file
+ def image_submit
+ render :text => "#{params[:x]},#{params[:y]}"
+ end
+
+ def image_submit_form
+ end
+
+end
diff --git a/spec/integration/rails/config/routes.rb b/spec/integration/rails/config/routes.rb
index 31a6c75..11da63d 100644
--- a/spec/integration/rails/config/routes.rb
+++ b/spec/integration/rails/config/routes.rb
@@ -3,6 +3,8 @@ ActionController::Routing::Routes.draw do |map|
webrat.submit "/submit", :action => "submit"
webrat.internal_redirect "/internal_redirect", :action => "internal_redirect"
webrat.external_redirect "/external_redirect", :action => "external_redirect"
+ webrat.image_submit "/image_submit", :action => "image_submit"
+ webrat.image_submit_form "/image_submit_form", :action => "image_submit_form"
webrat.root :action => "form"
end
diff --git a/spec/integration/rails/test/integration/webrat_test.rb b/spec/integration/rails/test/integration/webrat_test.rb
index eb56917..95e8840 100644
--- a/spec/integration/rails/test/integration/webrat_test.rb
+++ b/spec/integration/rails/test/integration/webrat_test.rb
@@ -24,4 +24,10 @@ class WebratTest < ActionController::IntegrationTest
visit external_redirect_path
assert response.redirect?
end
+
+ test "should pass x and y coordinates for image buttons" do
+ visit image_submit_form_path
+ click_button 'button-id', :x => 5, :y => 100
+ assert response.body.include?("5,100")
+ end
end