I just imported WWW::Mechanize::PhantomJS today that appeared to be successful using cpan WWW::Mechanize::PhantomJS. After the completion of the install/import, I used the default example program as a test and received this error:
'phantomjs' is not recognized as an internal or external command Question: How do I fix this problem?
This error is coming from this line in the test program:
my $mech = WWW::Mechanize::PhantomJS->new(
launch_arg => ['ghostdriver/src/main.js' ],
);
Here is the full code copied directly from the PhantomJS example code:
use strict;
use File::Spec;
use File::Basename 'dirname';
use WWW::Mechanize::PhantomJS;
my $url = 'https://radioa1a.com/trop-40-vote/';
my $mech = WWW::Mechanize::PhantomJS->new(
launch_arg => ['ghostdriver/src/main.js' ],
);
sub show_screen() {
my $page_png = $mech->content_as_png();
my $fn= File::Spec->rel2abs(dirname($0)) . "/screen.png";
open my $fh, '>', $fn
or die "Couldn't create '$fn': $!";
binmode $fh, ':raw';
print $fh $page_png;
close $fh;
#system(qq(start "Progress" "$fn"));
};
$mech->get($url);
show_screen;
The full error message from my Windows 10 command prompt window:
C:\Users\Bryon\Desktop\Perl>TestWebPage.pl
'phantomjs' is not recognized as an internal or external command,
operable program or batch file.
Selenium server did not return proper status at C:/Strawberry/perl/site/lib/Selenium/Remote/Driver.pm line 543.
C:\Users\Bryon\Desktop\Perl>
My environment:
- Windows 10 64-bit
Strawberry Perl version:
C:\Users\Bryon\Desktop\Perl>perl -v
This is perl 5, version 30, subversion 2 (v5.30.2) built for MSWin32-x64-multi-thread
Copyright 1987-2020, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Also, I see the PhantomJS module components in the C:\strawberry\perl\site\lib\wWW\Mechanize\PhantomJS\
So how do I fix this issue?
Thank you in advance for your help
phantomjs
tool, which needs to be installed and in your PATH. Note that development ofphantomjs
was abandoned two years ago. – ikegami