WWW:Mechanize:Firefox fails connection

I am creating a short Perl Script. I am using the WWW::Mechanize::Firefox module. When I instantiate the object, I believe the module fails to establish a connection with the MozRepl component in Firefox.

My code is as follows:

use WWW::Mechanize::Firefox;

my $mech = WWW::Mechanize::Firefox->new();

When I run the code, I get the following error message

Failed to connect to , problem connecting to "localhost", port 4242: Connection refused at /usr/local/share/perl/5.12.4/MoxRepl/Client.pm line 144'

I just installed and updated all relevant software I can think of

  • Perl 5.12.4
  • MozRepl Extension for Firefox
  • CPAN
  • MozRepl
  • WWW::Mechanize
  • WWW::Mechanize::Firefox
  • I tried adjusting the firewall to open port 4242. Nothing is working. Any ideas?

    A similar error code appears in this Stack Overflow question


    Update

    Ok, Borodin's answer actually fixed 2 problems.

    WWW::Mechanize::Firefox->new() only works when

  • The Firefox browser is already open, and
  • After starting Firefox, you follow Borodin's instructions and also start MozRepl
  • I had expected the Perl script to act like a shell script, and start Firefox for me. This is not the case.

    Also, if you hide the menu bar in Firefox, the "Tools" menu is the only menu that is not accessible in the drop-down list that appears on the top left. You have to show the menu bar to access the "Tools" menu.


    You need to start the MozRepl add-on in Firefox.

    Go to Tools / MozRepl and click on Start

    Your program should now work.

    链接地址: http://www.djcxy.com/p/57512.html

    上一篇: WWW :: Mechanize :: Firefox故障排除

    下一篇: WWW:机械化:Firefox无法连接