Reputation: 131
I get the following error when I run the little sample script:
Can't locate object method "new" via package "WWW::Mechanize::Firefox" (perhaps you forgot to load "WWW::Mechanize::Firefox"?) at mechtest.pl line 2.
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get('http://google.com');
$mech->eval_in_page('alert("Hello Firefox")');
my $png = $mech->content_as_png();
I have WWW::Mechanize::Firefox installed, I have the MozRepl plugin installed on Firefox. Why can't it find new?
Upvotes: 1
Views: 1653
Reputation: 51
Most likely you are on Windows and have an old version of WWW::Mechanize::Firefox installed. That old version was at the time (badly) named Fire_F_ox (note the upper case F). Look whether you have a file FireFox.pm on your machine.
Windows has case-insensitive filesystems and hence will happily load a file FireFox.pm even if you request to load a file Firefox.pm.
The solution is to uninstall WWW::Mechanize::FireFox and to install WWW::Mechanize::Firefox. Also, for future reports, it immensively helps if you tell us the version of Perl, the version(s) of the module(s) and the OS you use.
-max
Upvotes: 5
Reputation: 342363
The module requires some dependencies like MozRepl::RemoteObject
etc.
you should probably reinstall using cpan or ppm (if using ActiveState) etc
Upvotes: 1
Reputation: 13476
Sounds like WWW::Mechanize::Firefox isn't installed properly. Reboot and confirm that it's installed properly (cpan, ppm etc).
Upvotes: 1