Here's the basics of how the web testing object is set up. If WWW::Mechanize should automatically follow a redirect request, then perhaps there's something wrong I am doing in the setup?
package Foo::Webtest;
use strict;
use warnings;
use URI;
use Hook::LexWrap;
use WWW::Mechanize;
use Class::MethodMaker (
new => 'new',
object => [
'WWW::Mechanize' => {
slot => 'browser',
comp_mthds => [qw/
add_header agent_alias back base click
content ct current_form field find_all_links
find_link follow_link form_name form_number forms
get is_html links quiet redirect_ok
reload request response set_fields status
submit submit_form success tick title
untick uri
/],
}
]);
my $start_time;
my @times;
my %URI;
if ($ENV{TRACK_NAVIGATION}) {
foreach my $method (qw/back click follow_link get reload submit subm
+it_form/) {
wrap $method,
pre => sub {$start_time = time},
post => sub {
my $end_time = time;
my $time = $end_time - $start_time;
push @times => $time;
push @{$URI{$_[0]->base_uri}} => $time;
}
}
}
The above code is my setup for the Mechanize object. I use Class::MethodMaker to ensure that I have a "hasa" relationship to Mechanize and all methods listed are delegated to the Mechanize object. Then, Hook::LexWrap is called to allow me to (loosely) time the fetch methods.
Later, I can do this:
my $webtest = Foo::Webtest->new;
$webtest->get($page_to_test);
# and then use the code in my root post
(Note that this was pared down fairly quickly). I am wondering if my weird setup is causing the problem. All I know right now is that I receive a redirect, but the $webtest->content still points to the page the original form is on. I was hoping it was simply a quick question on how to get the form to automatically follow, but if it's not, I can spend some time paring this down to a minimal test case.
|