Hello,
So I recently created a script that get's a login page, fills out the form, and submits it, in order to test the functionality on a website. This code works perfectly fine on my desktop, however, when running it on my server, the get request seems to fail (with a 500 error) and I get a number of errors about missing or undefined object.
code snippet:
sub canLogin
{
$mech->get($loginurl);
$mech->save_content( 'login.html' );
print "Status code:".$mech->status()."\n";
if($@)
{
$loginfail = 1;
return "Could not load login page - Status Code: ".$mech->status();
}
print $mech->text();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->form_id('login-form');
$mech->field ('username' => $username);
$mech->field ('password' => $password);
eval { $mech->submit() };
$logintime = $mech->client_total_time;
if($@)
{
$loginfail = 1;
return "Could not login - Status Code: ".$mech->status();
}
if(index($mech->text(), "Login failed") != -1)
{
$loginfail = 1;
return "Page loaded fine but login failed, check credentials. ";
}
return "Login succeded: $logintime ms :- ";
}
On my desktop, this produces the following output:
Status code:200
Text content from page
On the server, I get
Status code:500
There is no form with ID "login-form" at ./check_boards_func line 52.
Can't call method "value" on an undefined value at /usr/local/share/perl/5.14.2/WWW/Mechanize.pm line 1407.
Can't locate object method "new" via package "LWPx::TimedHTTP::https::Socket" at /usr/local/share/perl/5.14.2/LWP/Protocol/http.pm line 31.
Both machines have the WWW::Mechanize and WWW::Mechanize::Timed modules installed, as well as LWPx::TimedHTTP::https, and both are running Ubuntu 12.04 x64.
Both using
WWW::Mechanize 1.72
WWW::Mechanize::Timed 0.44
ch...@chrisduffin.org reported on Oct 31, 2012
Details
Imported from Google Code issue 240 via archive
Comments
kabac...@gmail.com commented on Feb 4, 2013 :