Skip to content

Please raise error when attempting to set readonly textfield #1178

Confusion opened this Issue Oct 25, 2013 · 5 comments

5 participants


When a textfield has been marked 'readonly' and you call e.g. fill_in('text_field_id', with: value), it fails silently. Capybara::RackTest::Node#set simply does not execute the set, because of an unless self[:readonly]. Please raise an error if this is attempted: it would have saved me quite some time searching for why the set didn't work. I'm sure others have been surprised by this as well.


I'm not sure what happens if you try to do this with another driver, mostly with Selenium. The behaviour should be consistent, so we should adapt to what they do. This does make sense to me, so if you can work it up, please provide a pull request!


Since it seems like we have tested the current behaviour, that means we can't change it without doing a major version bump, which will probably take a while.

ametia commented Apr 27, 2014

It would be handy to be able to force set the field if needed. We are using datepicker that is 'readonly' so people are forced to pick and not fill it in but in the tests it is handy to just fill it in. I have just updated the version of capybara today and hit the same problem where setting a 'readonly' field gives you no warning.

@twalpole twalpole added this to the Capybara 3.0 milestone May 6, 2014
twalpole commented May 6, 2014

Forcing can be done by using execute_script if needed. Since capybara aims to replicate user interaction generally it won't be allowing for forcing the setting of values on readonly elements.

twalpole commented Jul 1, 2014

Clsing this now since attempting to set a readonly element will issue a warning in master now (2.4 to be released soon), it will raise an error whenever we move to v3

@twalpole twalpole closed this Jul 1, 2014
@abotalov abotalov removed this from the Capybara 3.0 milestone Jul 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.