Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/petdance/test-www-mechanize
Test::WWW::Mechanize, a Perl object for testing web pages
https://github.com/petdance/test-www-mechanize
bot hacktoberfest html perl testing
Last synced: about 2 months ago
JSON representation
Test::WWW::Mechanize, a Perl object for testing web pages
- Host: GitHub
- URL: https://github.com/petdance/test-www-mechanize
- Owner: petdance
- Created: 2011-04-24T03:36:34.000Z (over 13 years ago)
- Default Branch: dev
- Last Pushed: 2022-12-05T04:21:36.000Z (about 2 years ago)
- Last Synced: 2024-06-18T11:17:41.859Z (7 months ago)
- Topics: bot, hacktoberfest, html, perl, testing
- Language: Perl
- Homepage:
- Size: 449 KB
- Stars: 17
- Watchers: 5
- Forks: 23
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
# Test-WWW-Mechanize
* Build status: [![Build Status](https://github.com/petdance/test-www-mechanize/workflows/testsuite/badge.svg?branch=dev)](https://github.com/petdance/test-www-mechanize/actions?query=workflow%3Atestsuite+branch%3Adev)
* cpantesters.org:
[summary](http://www.cpantesters.org/distro/T/Test-WWW-Mechanize.html) and
[dev FAILures](http://www.cpantesters.org/distro/T/Test-WWW-Mechanize.html?grade=3&perlmat=2&patches=2&oncpan=2&distmat=3&perlver=ALL&osname=ALL&version=1.44)----
Test::WWW::Mechanize is a subclass of the Perl module WWW::Mechanize
that incorporates features for web application testing. For example:use Test::WWW::Mechanize;
my $mech = Test::WWW::Mechanize->new;
$mech->get_ok( $page );
$mech->base_is( 'http://petdance.com/', 'Proper ' );
$mech->title_is( 'Invoice Status', "Make sure we're on the invoice page" );
$mech->text_contains( 'Andy Lester', 'My name somewhere' );
$mech->content_like( qr/(cpan|perl)\.org/, 'Link to perl.org or CPAN' );
$mech->header_is( 'Cache-Control', 'private', 'Caching is turned off' );
$mech->lacks_header_ok( 'X-Foo', 'Does not have the X-Foo header' );This is equivalent to:
use WWW::Mechanize;
my $mech = WWW::Mechanize->new;
$mech->get( $page );
ok( $mech->success );
is( $mech->base, 'http://petdance.com', 'Proper ' );
is( $mech->title, 'Invoice Status', "Make sure we're on the invoice page" );
ok( index( $mech->content( format => 'text' ), 'Andy Lester' ) >= 0, 'My name somewhere' );
like( $mech->content, qr/(cpan|perl)\.org/, 'Link to perl.org or CPAN' );
is( $mech->response->header( 'Cache-Control' ), 'private', 'Caching is turned off' );
ok( !defined $mech->response->header( 'X-Foo' ), 'Does not have the X-Foo header' );but has nicer diagnostics if they fail.
Test::WWW::Mechanize also has functionality to automatically validate every page it goes to.
use Test::WWW::Mechanize;
my $mech = Test::WWW::Mechanize->new( autotidy => 1 );
$mech->get_ok( $url );which can give errors like this:
not ok 1 - GET $url
# Failed test '$url'
# at foo.pl line 7.
# HTML::Tidy5 messages for $url
# (11:1) Warning: missing before