File: follow_link.t

package info (click to toggle)
libwww-mechanize-perl 1.18-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 488 kB
  • ctags: 109
  • sloc: perl: 2,315; makefile: 39
file content (28 lines) | stat: -rw-r--r-- 743 bytes parent folder | download
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
#!perl -T

use warnings;
use strict;
use Test::More tests => 7;
use constant START => 'http://www.google.com/intl/en/';

BEGIN {
    use_ok( 'WWW::Mechanize' );
}

my $agent = WWW::Mechanize->new;
isa_ok( $agent, 'WWW::Mechanize' );

my $response = $agent->get( START );
ok( $response->is_success, 'Got some page' ) or die "Can't even get Google";
is( $agent->uri, START, 'Got Google' );

$response = $agent->follow_link( text_regex => qr/Advertising.Programs/i );
ok( $response->is_success, 'Got the page' );
is( $agent->uri, 'http://www.google.com/ads/', "Got the correct page" );

SKIP: {
    eval "use Test::Memory::Cycle";
    skip "Test::Memory::Cycle not installed", 1 if $@;

    memory_cycle_ok( $agent, "No memory cycles found" );
}