简体   繁体   中英

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 Files\Mozilla Firefox\firefox.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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM