WWW: Mechanize: Firefox can't connect

I am creating a short Perl Script. I am using a module WWW::Mechanize::Firefox

. When I instantiate the object, I find that the module is unable to establish a connection with the MozRepl component in Firefox.

My code looks like this:

use WWW::Mechanize::Firefox;

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

      

When I run the code the following error appears

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 the relevant programs I can think of

  • Perl 5.12.4
  • MozRepl extension for Firefox
  • CPAN
  • MozRepl
  • WWW :: Mechanize
  • WWW :: Mechanize :: Firefox

I tried to configure my firewall to open port 4242. Nothing works. Any ideas?

A similar error code appears in this question


Update

Ok, Borodin's answer actually fixed 2 problems.

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

  • Firefox browser is already open and
  • After Firefox starts, follow Borodin's instructions and also launch MozRepl

I expected the Perl script to act like a shell script and launch Firefox for me. This is not true.

Also, if you hide the menu bar in Firefox, the Tools menu is the only menu that is not available in the dropdown that appears in the top left corner. You must display the menu bar to access the Tools menu.

+3


source to share


1 answer


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

Go to Tools / MozRepl and click Post



Your program should work.

+7


source







All Articles