Have you seen Test::WWW::Mechanize? You can do much better if you adopt its use with a less data driven approach.
my $question = {
1 => 'value_12345',
2 => 'value_12346',
3 => 'value_12347',
};
my @test = (
'First page of sequence' => sub {
my ( $mech, $name ) = @_;
$mech->get( qq[some_uri] );
$mech->content_like( qr/Some text/, $name );
$mech->click;
},
'page seen after first click' => sub {
my ( $mech, $name ) = @_;
$mech->content_like( qr/Dst1/, "$name: destination1" );
$mech->submit_form( fields => {
$question->{ 1 } => 3, # Q1, choice 3 (radio button)
} );
},
'page seen after second POST' => sub {
my ( $mech, $name ) = @_;
$mech->content_like( qr/Dst2/, "$name: destination2" ],
$mech->content_like( qr/more text/, "$name: more text expected
+" ],
$mech->submit_form( fields => {
# ...
} );
$mech->back;
$mech->back;
},
);
my $verbose = 0;
my $mech = Test::WWW::Mechanize->new( ... );
while( my ( $name, $test ) = splice @test, 0, 2 ) {
$test->( $mech, $name );
diag $mech->current_form->dump if $verbose;
sleep 1;
}
Makeshifts last the longest.
|