Method: Capybara::Node::Element#set

Defined in:
lib/capybara/node/element.rb

#set(value, **options) ⇒ Capybara::Node::Element

Set the value of the form element to the given value.

Parameters:

  • value (String)

    The new value

  • options (Hash)

    Driver specific options for how to set the value. Take default values from default_set_options.

Returns:



117
118
119
120
121
122
123
124
125
# File 'lib/capybara/node/element.rb', line 117

def set(value, **options)
  if ENV.fetch('CAPYBARA_THOROUGH', nil) && readonly?
    raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}"
  end

  options = session_options.default_set_options.to_h.merge(options)
  synchronize { base.set(value, **options) }
  self
end