Debian lenny version packages
[pkg-perl] / deb-src / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / local / click.t
1 #!perl
2
3 use warnings;
4 use strict;
5 use lib 't/local';
6 use LocalServer;
7 use Test::More tests => 10;
8
9 BEGIN {
10     delete @ENV{ grep { lc eq 'http_proxy' } keys %ENV };
11     delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) };
12     use_ok( 'WWW::Mechanize' );
13 }
14
15 my $mech = WWW::Mechanize->new();
16 isa_ok( $mech, 'WWW::Mechanize', 'Created the object' );
17
18 my $server = LocalServer->spawn();
19 isa_ok( $server, 'LocalServer' );
20
21 my $response = $mech->get( $server->url );
22 isa_ok( $response, 'HTTP::Response', 'Got back a response' );
23 ok( $response->is_success, 'Got URL' ) or die q{Can't even fetch local url};
24 ok( $mech->is_html, 'Local page is HTML' );
25 my @forms = $mech->forms;
26 is( scalar @forms, 1, 'Only one form' );
27
28 $mech->field(query => 'foo'); # Filled the 'q' field
29
30 $response = $mech->click('submit');
31 isa_ok( $response, 'HTTP::Response', 'Got back a response' );
32 ok( $response->is_success, q{Can click 'Go' ('Google Search' button)} );
33
34 is( $mech->field('query'),'foo', 'Filled field correctly');
35