... my $mech = WWW::Mechanize->new(...); my $question = { 1 => 'value_12345', 2 => 'value_12346', 3 => 'value_12347', }; my $test_list = [ { name => 'First page of sequence', check_list => [ # Things to compare content to on this page [ qr/Some text/, "test name" ], ], action => sub { # Action to perform from this page $mech->click; }, }, { name => 'page seen after first click', check_list => [ [ qr/Dst1/, "destination1" ], ], action => sub { $mech->submit_form( fields => { $question->{1} => 3, # Q1, choice 3 (radio button) }); }, }, { name => 'page seen after second POST', check_list => [ [ qr/Dst2/, "destination2" ], [ qr/more text/, "more text expected on this page" ], ], action => sub { $mech->submit_form( fields => { $mech->back; $mech->back; }); }, }, ]; $mech->get(qq[some_uri]); my $verbose = 0; for my $test(@$test_list) { my $name = $test->{name}; my $check_list = $test->{check_list}; for my $check(@$check_list) { like($mech->content, $check->[0], "test $name - $check->[1]"); } diag $mech->current_form->dump if $verbose; if ($test->{action}) { $test->{action}->(); } sleep 1; # Optional }