I cannot edit a field with mechanize

374 views Asked by At

I am developing a Rails application and I am using mechanize to automate the changing of a profile. Currently I am trying to change a field date that has some sort of mask, as it only displays the format. (dd/mm/yyyy). It has two fields: Birth_Date_Visible, text input, and Birth_Date, hidden_field. I cannot change the hidden field as doing so and submitting the form raises me a 500 server error: unhandled response.

Any ideas on how to do that?

1

There are 1 answers

2
Nikita Kovalyov On BEST ANSWER

The problem may be that you didn't change hidden control readonly attr.

From Mechanize FAQ:

How do I change INPUT TYPE=HIDDEN field values (for example, to emulate the effect of JavaScript code)? As with any control, set the control’s readonly attribute false.

form.find_control("foo").readonly = False # allow changing .value of control foo
form.set_all_readonly(False) # allow changing the .value of all controls