5 use HTTP::Request::Common;
9 my $cookie_jar = HTTP::Cookies->new;
10 my $agent = WWW::Mechanize->new();
12 # give the agent a place to stash the cookies
14 $agent->cookie_jar($cookie_jar);
18 my $url = "http://localhost/";
21 is ($agent->{'status'}, 200, "Loaded a page");
26 # follow the link marked "Login"
28 ok($agent->{form}->find_input('user'));
30 ok($agent->{form}->find_input('pass'));
31 ok ($agent->{'content'} =~ /username:/i);
32 $agent->field( 'user' => 'root' );
33 $agent->field( 'pass' => 'password' );
34 # the field isn't named, so we have to click link 0
36 is($agent->{'status'}, 200, "Fetched the page ok");
37 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
41 find ( \&wanted , 'html/');
44 -f && /\.html$/ && $_ !~ /Logout.html$/ && test_get($File::Find::name);
52 ok ($agent->get("$url/$file", "GET $url/$file"));
53 is ($agent->{'status'}, 200, "Loaded $file");
54 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file ");
55 ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for $file");
56 ok( $agent->{'content'} !~ /System error/i, "Didn't get a Mason compilation error on $file");