3
Test::WWW::Mechanize is a subclass of the Perl module WWW::Mechanize
4
that incorporates features for web application testing. For example:
6
use Test::More tests => 5;
7
use Test::WWW::Mechanize;
9
my $mech = Test::WWW::Mechanize->new;
10
$mech->get_ok( $page );
11
$mech->base_is( 'http://petdance.com/', 'Proper <BASE HREF>' );
12
$mech->title_is( 'Invoice Status', "Make sure we're on the invoice page" );
13
$mech->text_contains( 'Andy Lester', 'My name somewhere' );
14
$mech->content_like( qr/(cpan|perl)\.org/, 'Link to perl.org or CPAN' );
16
This is equivalent to:
18
use Test::More tests => 5;
21
my $mech = WWW::Mechanize->new;
24
is( $mech->base, 'http://petdance.com', 'Proper <BASE HREF>' );
25
is( $mech->title, 'Invoice Status', "Make sure we're on the invoice page" );
26
ok( index( $mech->content( format => 'text' ), 'Andy Lester' ) >= 0, 'My name somewhere' );
27
like( $mech->content, qr/(cpan|perl)\.org/, 'Link to perl.org or CPAN' );
29
but has nicer diagnostics if they fail.
33
To install this module, run the following commands:
40
# COPYRIGHT AND LICENSE
42
Copyright (C) 2004-2012 Andy Lester
44
This library is free software; you can redistribute it and/or modify it
45
under the terms of the Artistic License version 2.0.