简体   繁体   English

WWW :: Mechanize :: Firefox故障排除

[英]WWW::Mechanize::Firefox troubleshooting

I have MozRepl installed in my browser and set to start on startup and accept outside connections. 我在浏览器中安装了MozRepl,并设置为在启动时启动并接受外部连接。

So my questions are as follows 1) will simply running the code my $mech = WWW::Mechanize::Firefox->new(); 所以我的问题如下:1)只需运行代码my $mech = WWW::Mechanize::Firefox->new(); launch the firefox browser? 启动firefox浏览器?

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 . 2)我已将MozRepl设置为接受外部连接,但是当firefox未启动时,当我的脚本到达1)中的代码时,它告诉我unable to connect, problem connecting to localhost, on port 4242 I tried to debug by doing telnet localhost 4242 with firefox browser not launched. 我尝试通过使用未启动的Firefox浏览器执行telnet localhost 4242进行调试。 It also gives me this error Could not open connection to the host, on port 4242: Connect failed . 它还给我这个错误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. 3)鉴于我遇到的困难,我决定在创建mechanize :: firefox实例之前使用system()启动浏览器。 The browser is able to start, however it never reaches the code where mechanize::firefox instance is to be created. 浏览器能够启动,但它永远不会到达要创建mechanize :: firefox实例的代码。

#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? 我该怎么做才能确保firefox浏览器可以启动但它不会影响代码的顺序,这样可以创建mechanize :: firefox实例来操作浏览器?

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. 我花时间启动firefox,但系统在firefox启动后立即返回。 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. 最简单的方法是通过睡眠等待30秒,或者启动一个while循环等待它响应。

It is possible that a firewall rule prevent you access mozrepl. 防火墙规则可能会阻止您访问mozrepl。 The default port is 4242. check the port via telnet: 默认端口是4242.通过telnet检查端口:

telnet 192.168.1.23 4242
telnet 127.0.0.1 4242

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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