mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Implementation for issue #1319 - propagate fill_in options to Element#set
This commit is contained in:
parent
6ba0c70ade
commit
2ce36695eb
3 changed files with 24 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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
|
||||
|
||||
##
|
||||
|
|
Loading…
Reference in a new issue