1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!perl -T
use warnings;
use strict;
use Test::More tests => 26;
use Test::LongString;
BEGIN {
use_ok( 'WWW::Mechanize' );
}
my $agent = WWW::Mechanize->new;
isa_ok( $agent, 'WWW::Mechanize' );
ok($agent->get("http://www.google.com/intl/en/")->is_success, "Get google webpage");
is( ref $agent->uri, "", "URI should be a string, not an object" );
ok( $agent->is_html, "Seems to be HTML" );
is( $agent->title, "Google", "Title matches" );
my $services = $agent->find_link( url_regex => qr[/ads/] );
isa_ok( $services, 'WWW::Mechanize::Link' );
ok( $agent->get( $services )->is_success, 'Got the ads page' );
is( $agent->uri, 'http://www.google.com/ads/', "Got relative OK" );
ok( $agent->is_html );
is( $agent->title, "Google Advertising", "Got the right page" );
ok( $agent->get( '../support/' )->is_success, 'Got the support page' );
is( $agent->uri, 'http://www.google.com/support/', "Got relative OK" );
ok( $agent->is_html );
is( $agent->title, "Google: Help Center", "Title matches" );
ok( $agent->get( '../help/basics.html' )->is_success, 'Got the basics page' );
is( $agent->uri, 'http://www.google.com/help/basics.html', "Got relative OK" );
ok( $agent->is_html, "Basics page is HTML" );
is( $agent->title, "Google Help : Basics of Search", "Title matches" );
like_string( $agent->content, qr/Essentials of Google Search/, "Got the right page" );
ok( $agent->get( './refinesearch.html' )->is_success, 'Got the "refine search" page' );
is( $agent->uri, 'http://www.google.com/help/refinesearch.html', "Got relative OK" );
ok( $agent->is_html, "Refine Search page is HTML" );
is( $agent->title, "Google Help : Advanced Search" );
like_string( $agent->content, qr/Advanced Search Made Easy/, "Got the right page" );
SKIP: {
eval "use Test::Memory::Cycle";
skip "Test::Memory::Cycle not installed", 1 if $@;
memory_cycle_ok( $agent, "No memory cycles found" );
}
|