ferhatelmas
ferhatelmas

Reputation: 3978

How to authorize with Test::WWW::Mechanize

I want to test a .htaccess protected page with Test::WWW::Mechanize but I don't know how can I send credentials for the page? I couldn't find a function that can handle this.

Upvotes: 1

Views: 463

Answers (1)

singingfish
singingfish

Reputation: 3167

use Test::WWW::Mechanize;
my $mech = Test::WWW::Mechanize->new();
my ($user, $pass) = qw/user pass/;
$mech->credentials($user, $pass);
$mech->get_ok('http://example.com');

Upvotes: 7

Related Questions