NAME
Test::WWW::Mechanize - The great new Test::WWW::Mechanize!
Version
Version 0.04
Synopsis
Test::WWW::Mechanize is a subclass of WWW::Mechanize that incorporates features that make sense for doing web application testing. For example:
$mech->get( $page );
$mech->title_is( "Invoice Status", "Make sure we're on the invoice page" );
This is equivalent to:
$mech->get( $page );
is( $mech->title, "Invoice Status", "Make sure we're on the invoice page" );
but has nicer error handling.
Constructor
new
Behaves like, and calls, WWW::Mechanize's new
method. Any parms passed in get passed to WWW::Mechanize's constructor.
Methods
title_is( $str [, $msg ] )
Tells if the title of the page is the given string.
$mech->title_is( "Invoice Summary" );
title_like( $regex [, $msg ] )
Tells if the title of the page matches the given regex.
$mech->title_like( qr/Invoices for (.+)/
content_is( $str [, $msg ] )
Tells if the content of the page matches the given string
content_like( $regex [, $msg ] )
Tells if the content of the page matches the given regex
links_ok( $links [, $msg ] )
Check the current page for specified links and test for HTTP status 200. The links may be specified as a reference to an array containing WWW::Mechanize::Link objects, an array of URLs, or a scalar URL name.
my @links = $mech->find_all_links( url_regex => qr/cnn\.com$/ );
$mech->links_ok( \@links, 'Check all links for cnn.com' );
my @links = qw( index.html search.html about.html );
$mech->links_ok( \@links, 'Check main links' );
$mech->links_ok( 'index.html', 'Check link to index' );
page_links_ok( [ $msg ] )
Follow all links on the current page and test for HTTP status 200
$mech->page_links_ok('Check all links');
link_status_is( $links, $status [, $msg ] )
Check the current page for specified links and test for HTTP status passed. The links may be specified as a reference to an array containing WWW::Mechanize::Link objects, an array of URLs, or a scalar URL name.
my @links = $mech->links();
$mech->link_status_is( \@links, 403,'Check all links are restricted' );
To-do
Test suite
Add HTML::Lint and HTML::Tidy capabilities.
Author
Andy Lester, <andy@petdance.com>
Bugs
Please report any bugs or feature requests to bug-test-www-mechanize@rt.cpan.org
, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
Copyright & License
Copyright 2004 Andy Lester, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.