Raise error when attempting to set a readonly field

This commit is contained in:
Thomas Walpole 2016-08-17 12:49:08 -07:00
parent 05945bf2d9
commit 98b9034842
2 changed files with 3 additions and 3 deletions

View File

@ -97,6 +97,8 @@ module Capybara
def set(value, options={})
options ||= {}
raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}" if readonly?
driver_supports_options = (base.method(:set).arity != 1)
unless options.empty? || driver_supports_options

View File

@ -225,9 +225,7 @@ private
end
def set_text(value, options)
if readonly?
warn "Attempt to set readonly element with value: #{value} \n *This will raise an exception in a future version of Capybara"
elsif value.to_s.empty? && options[:clear].nil?
if value.to_s.empty? && options[:clear].nil?
native.clear
else
if options[:clear] == :backspace