diff --git a/lib/capybara/driver/node.rb b/lib/capybara/driver/node.rb index 017b390d..1a9c0686 100644 --- a/lib/capybara/driver/node.rb +++ b/lib/capybara/driver/node.rb @@ -25,7 +25,8 @@ module Capybara end # @param value String or Array. Array is only allowed if node has 'multiple' attribute - def set(value) + # @param options [Hash{}] Driver specific options for how to set a value on a node + def set(value, options={}) raise NotImplementedError end diff --git a/lib/capybara/node/actions.rb b/lib/capybara/node/actions.rb index b29d3b26..3603c38a 100644 --- a/lib/capybara/node/actions.rb +++ b/lib/capybara/node/actions.rb @@ -45,12 +45,15 @@ module Capybara # page.fill_in 'Name', :with => 'Bob' # # @param [String] locator Which field to fill in - # @param [Hash{:with => String}] options The value to fill in + # @param [Hash] options + # @option options [String] :with The value to fill in - required + # @option options [Hash] :fill_options Driver specific options regarding how to fill fields # def fill_in(locator, options={}) raise "Must pass a hash containing 'with'" if not options.is_a?(Hash) or not options.has_key?(:with) with = options.delete(:with) - find(:fillable_field, locator, options).set(with) + fill_options = options.delete(:fill_options) + find(:fillable_field, locator, options).set(with, fill_options) end ## diff --git a/lib/capybara/node/element.rb b/lib/capybara/node/element.rb index 21cbe209..c9fcf42d 100644 --- a/lib/capybara/node/element.rb +++ b/lib/capybara/node/element.rb @@ -89,9 +89,24 @@ module Capybara # Set the value of the form element to the given value. # # @param [String] value The new value + # @param [Hash{}] options Driver specific options for how to set the value # - def set(value) - synchronize { base.set(value) } + def set(value, options={}) + options ||= {} + + driver_supports_options = (base.method(:set).arity != 1) + + unless options.empty? || driver_supports_options + warn "Options passed to Capybara::Node#set but the driver doesn't support them" + end + + synchronize do + if driver_supports_options + base.set(value, options) + else + base.set(value) + end + end end ##