Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

mpeters (5802)

  (email not shown publicly)
AOL IM: michael00peters (Add Buddy, Send Message)

Technorati Profile []

Journal of mpeters (5802)

Thursday June 15, 2006
02:04 PM

Mech and hidden fields

[ #29922 ]

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');
    $mech->set_fields(rm => 'foo');

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.