readonly support

This commit is contained in:
Thomas Walpole 2013-03-09 13:42:35 -08:00
parent 99c54cf152
commit 48185aa073
2 changed files with 5 additions and 4 deletions

View File

@ -27,7 +27,7 @@ class Capybara::RackTest::Node < Capybara::Driver::Node
elsif input_field?
set_input(value)
elsif textarea?
native.content = value.to_s
native.content = value.to_s unless self[:readonly]
end
end
@ -160,7 +160,7 @@ private
end
native.remove
else
native['value'] = value.to_s
native['value'] = value.to_s unless self[:readonly]
end
end

View File

@ -37,7 +37,8 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
path_names = value.to_s.empty? ? [] : value
native.send_keys(*path_names)
elsif tag_name == 'textarea' or tag_name == 'input'
driver.browser.execute_script "arguments[0].value = ''", native
#script can change a readonly element which user input cannot, so dont execute if readonly
driver.browser.execute_script "arguments[0].value = ''", native unless self[:readonly]
native.send_keys(value.to_s)
end
end