WWW::Mechanize::Firefox troubleshooting
I have MozRepl installed in my browser and set to start on startup and accept outside connections.
So my questions are as follows 1) will simply running the code my $mech = WWW::Mechanize::Firefox->new();
launch the firefox browser?
2) I have set MozRepl to accept outside connections however, while firefox is not launched, when my script reaches the code in 1), it tells me unable to connect, problem connecting to localhost, on port 4242
. I tried to debug by doing telnet localhost 4242
with firefox browser not launched. It also gives me this error Could not open connection to the host, on port 4242: Connect failed
.
Should i be expecting this result?
3) Given the difficulties I'm experiencing above, I decided to use system() to launch the browser before creating mechanize::firefox instance. The browser is able to start, however it never reaches the code where mechanize::firefox instance is to be created.
#where i manually fire up firefox.
system('"C:Program FilesMozilla Firefoxfirefox.exe"');
my $mech = WWW::Mechanize::Firefox->new(ssl_opts => { verify_hostname => 0});
$mech->get( 'https://192.168.1.23' );
What can i do to make sure firefox browser can be launched yet it will not affect the sequence of the code, such that mechanize::firefox instance can be created to manipulate the browser?
You have to start your browser before your test, it is not started automaticaly.
I takes time to start firefox, but system returns instantly after firefox started. I takes some seconds to initialize all of its plugins, etc.
The easiest thing is to wait 30 sec via sleep, or you start a while loop to wait until it is responding.
It is possible that a firewall rule prevent you access mozrepl. The default port is 4242. check the port via telnet:
telnet 192.168.1.23 4242
telnet 127.0.0.1 4242
链接地址: http://www.djcxy.com/p/57514.html