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');
suggestion: put it on annocpan (Score:1)
http://www.annocpan.org/dist/WWW-Mechanize-1.18/lib/WWW/Mechanize.pm [annocpan.org]
Re:suggestion: put it on annocpan (Score:1)
Mech is a little weak in general (Score:1)
In the end, I wrote my own web automation layer that is capable of running under "combat conditions" (broken HTML, crazy evil anti-scraping techniques, sites that change the page layout regularly etc).
Re:Mech is a little weak in general (Score:1)
Thanks (Score:1)
I'll check AnnoCPAN for others. Would make a nice Util plugin for WWW::Mechanize::Pluggable.