I was writing some controller tests for an application that makes heavy use of Javascript and it bit me again that WWW::Mechanize does not allow you to set the values of hidden fields, since HTML::Form considers them read-only.
This has always bugged since if Mech is going to be useful for testing it's almost required that you mess with hidden fields because sometimes your JS will do it, or you want to make sure you've protected yourself against elementary hacking attempts.
Anyway, I always forget how to work around this, so I'm putting it here to always remind myself. If you have a hidden input named 'rm', this is how you would make it settable for Mech:
my $form = $mech->form_name('my_form'); $form->find_input('rm')->readonly(0); $mech->set_fields(rm => 'foo');
Re:suggestion: put it on annocpan
mpeters on 2006-06-16T14:46:46
Excellent idea and it has been added - http://www.annocpan.org/user/PETDANCE/WWW-Mechanize-1.18/lib/WWW/Mechanize.pm#221
Re:Mech is a little weak in general
pemungkah on 2006-06-17T00:12:14
Have you released it? I'm definitely interested.