http://www.perlmonks.org?node_id=760987


in reply to The age old JavaScript WWW::Mech scenario

Without specifying which, mech automatically selects the first form; you need to select the second form on that url, so:
$mech->submit_form( form_number => 2, fields =>{ sess => "summer", course => $prefix, }, );
gives me something.

UPDATE:...and that something wasn't good.

I've always found it easier to debug form automation in WWW::Mechanize by doing one thing at a time. This works for me:

use WWW::Mechanize; use HTML::TokeParser; my $mech = WWW::Mechanize->new(cookie_jar => undef); $url="http://www.utsc.utoronto.ca/~registrar/scheduling/timetable"; $prefix = "ANT"; $mech->get($url); $mech->form_number(2); $mech->set_visible( [radio => 'summer'] ); # page default anyway $mech->select( 'course', $prefix ); $mech->click_button( name => 'submit' ); print $mech->content();

- clarified first sentence.