Special_K has asked for the wisdom of the Perl Monks concerning the following question:

I just installed

WWW::Mechanize::Firefox

but cannot even get it to complete this simple script:

#!/usr/bin/perl -w use strict; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(activate => 1); $mech->get("http://www.google.com"); printf("title: %s\n", $mech->title()); $mech->document(); $mech->content();

When I run it, I get the following response:

> www_mech_firefox_test.pl command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.pm lin +e 186

Here is what I have verified so far:

1. mozrepl is installed and started within Firefox
2. port 4242 TCP/UDP is forwarded to my PC through my router
3. I can run "telnet localhost 4242" and get a MozRepl prompt

What else could be causing this problem?

EDIT: This is under cygwin, if it makes any difference.

Replies are listed 'Best First'.
Re: can't get www::mechanize::firefox to work
by Khen1950fx (Canon) on Apr 13, 2013 at 05:42 UTC
    It works for me. Try installing Task::Mechanistic::Firefox. There are loads of dependencies that need to be installed before you install Mechanize.

      I installed www::mechanize::firefox through CPAN. Isn't it supposed to handle all dependencies automatically?

        CPAN does exactly what it is told to do. The authors of the dependencies are supposed to to tell it to install prerequisites: however, they don't always do that, so some dependencies end up in the wind, causing the problems that you are encountering.
Re: can't get www::mechanize::firefox to work
by Anonymous Monk on Apr 13, 2013 at 06:35 UTC

    What else could be causing this problem?

    Did you run the test suite successfully?

      UPDATE: Apparently none of the tests ran successfully. I walked away from my computer while the install was running and when I came back I only looked at the bottom line that said Result: PASS.

      In reality, it looks like the vast majority of the tests failed. I reran the tests and here is the actual output (I get the same output if I try to resintall the module using CPAN):

      /home/user1/.cpan/build/WWW-Mechanize-Firefox-0.71-sk8Ee1[155]> make t +est Skip blib/lib/Firefox/Application/API35.pm (unchanged) Skip blib/lib/Firefox/Application/API36.pm (unchanged) Skip blib/lib/WWW/Mechanize/Firefox/Troubleshooting.pod (unchanged) Skip blib/lib/WWW/Mechanize/Firefox.pm (unchanged) Skip blib/lib/Firefox/Application.pm (unchanged) Skip blib/lib/WWW/Mechanize/Firefox/Cookbook.pod (unchanged) Skip blib/lib/WWW/Mechanize/Firefox/DSL.pm (unchanged) Skip blib/lib/Firefox/Application/API40.pm (unchanged) Skip blib/lib/HTTP/Cookies/MozRepl.pm (unchanged) Skip blib/lib/HTML/Display/MozRepl.pm (unchanged) Skip blib/lib/WWW/Mechanize/Firefox/FAQ.pod (unchanged) Skip blib/lib/WWW/Mechanize/runtests.pl (unchanged) Skip blib/lib/WWW/Mechanize/Firefox/Installation.pod (unchanged) Skip blib/lib/WWW/Mechanize/Firefox/Examples.pm (unchanged) PERL_DL_NONLAZY=1 /usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "te +st_harness(0, 'blib/lib', 'blib/arch')" t/00-load.t t/01-mech-destroy +.t t/47-mech-memleak2.t t/47-mech-ref-memleak.t t/47-mech-simplest.t +t/48-mech-launch.t t/49-mech-get-file.t t/49-mech-nav.t t/49-mech-reu +se.t t/50-allow-js.t t/50-app-new.t t/50-app-profile.t t/50-click.t t +/50-follow-link.t t/50-form-with-fields.t t/50-form2.t t/50-load-and- +load.t t/50-mech-activateTab.t t/50-mech-bufsize.t t/50-mech-closeTab +.t t/50-mech-content.t t/50-mech-ct.t t/50-mech-encoding.t t/50-mech- +error.t t/50-mech-event.t t/50-mech-forms.t t/50-mech-get-nocache.t t +/50-mech-get.t t/50-mech-multi-event.t t/50-mech-new-dsl.t t/50-mech- +new-with-tab.t t/50-mech-new.t t/50-mech-save-dialog.t t/50-mech-set- +fields-875912.t t/50-mech-status.t t/50-popup.t t/50-rt65615.t t/50-t +ick.t t/51-click_button.t t/51-click_js.t t/51-form-number-blakew.t t +/51-mech-field.t t/51-mech-form-with-fields.t t/51-mech-links.t t/51- +mech-navigation.t t/51-mech-sandbox.t t/51-mech-set-content.t t/51-me +ch-submit.t t/52-frame-document.t t/52-frame-event.t t/52-mech-api-fi +nd_link-frames.t t/52-mech-api-find_link.t t/52-mech-xpath.t t/52-sel +ector-frames.t t/52-selector-noframes.t t/52-selector-relative.t t/53 +-mech-capture-js-error.t t/55-basic-auth.t t/60-mech-cookies.t t/60-m +ech-custom-headers.t t/65-is_visible.t t/65-mech-meta.t t/65-set_visi +ble.t t/70-download-url.t t/70-mech-png.t t/70-real-status.t t/70-rt7 +0106-reload.t t/70-rt71216.t t/70-tag-team.t t/70-two-instances.t t/7 +0-urlbar.t t/75-save_url-cookies.t t/99-changes.t t/99-examples.t t/9 +9-manifest.t t/99-pod.t t/99-todo.t t/99-unix-text.t t/99-versions.t +t/rt65615.t t/rt78706.t t/select.t t/mechanize/autocheck.t t/mechaniz +e/content.t t/00-load.t ....................... 1/1 # Testing WWW::Mechanize::Fire +fox 0.71, Perl 5.014002 # Carp 1.26 # Config <unknown> # DynaLoader 1.13 # Encode 2.49 # Encode::Alias 2.16 # Encode::Config 2.05 # Encode::Encoding 2.05 # Exporter 5.67 # Exporter::Heavy 5.67 # Fcntl 1.11 # File::Basename 2.82 # Firefox::Application 0.71 # HTML::Selector::XPath 0.15 # HTTP::Cookies 6.01 # HTTP::Cookies::MozRepl 0.71 # HTTP::Cookies::Netscape 6.00 # HTTP::Date 6.02 # HTTP::Headers 6.00 # HTTP::Headers::Util 6.03 # HTTP::Message 6.03 # HTTP::Response 6.03 # HTTP::Status 6.03 # JSON 2.53 # JSON::XS 2.32 # List::Util 1.27 # MIME::Base64 3.13 # MozRepl::RemoteObject 0.36 # MozRepl::RemoteObject::Methods 0.36 # PerlIO 1.07 # Scalar::Util 1.27 # Storable 2.27 # Test::Builder 0.98 # Test::Builder::Module 0.98 # Test::More 0.98 # Time::HiRes 1.9725 # Time::Local 1.2000 # URI 1.60 # URI::Escape 3.31 # WWW::Mechanize::Firefox 0.71 # WWW::Mechanize::Link <unknown> # XSLoader 0.13 # attributes 0.14 # base 2.16 # bytes 1.04 # common::sense 3.6 # constant 1.25 # overload 1.13 # parent 0.225 # re 0.18 # strict 1.04 # utf8 1.09 # vars 1.02 # warnings 1.12 # warnings::register 1.02 t/00-load.t ....................... ok t/01-mech-destroy.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/47-mech-memleak2.t .............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/47-mech-ref-memleak.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/47-mech-simplest.t .............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/48-mech-launch.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/49-mech-get-file.t .............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/49-mech-nav.t ................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/49-mech-reuse.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-allow-js.t ................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-app-new.t .................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-app-profile.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-click.t ...................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-follow-link.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-form-with-fields.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-form2.t ...................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-load-and-load.t .............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-activateTab.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-bufsize.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-closeTab.t .............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-content.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-ct.t .................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-encoding.t .............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-error.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-event.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-forms.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-get-nocache.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-get.t ................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-multi-event.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-new-dsl.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-new-with-tab.t .......... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-new.t ................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-save-dialog.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-set-fields-875912.t ..... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-mech-status.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-popup.t ...................... skipped: Opening windows are not y +et tracked t/50-rt65615.t .................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/50-tick.t ....................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-click_button.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-click_js.t ................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-form-number-blakew.t ......... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-mech-field.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-mech-form-with-fields.t ...... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-mech-links.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-mech-navigation.t ............ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-mech-sandbox.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-mech-set-content.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/51-mech-submit.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-frame-document.t ............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-frame-event.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-mech-api-find_link-frames.t .. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-mech-api-find_link.t ......... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-mech-xpath.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-selector-frames.t ............ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-selector-noframes.t .......... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/52-selector-relative.t .......... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/53-mech-capture-js-error.t ...... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/55-basic-auth.t ................. skipped: presetting auth does not +work yet t/60-mech-cookies.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/60-mech-custom-headers.t ........ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/65-is_visible.t ................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/65-mech-meta.t .................. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/65-set_visible.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-download-url.t ............... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-mech-png.t ................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-real-status.t ................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-rt70106-reload.t ............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-rt71216.t .................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-tag-team.t ................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-two-instances.t .............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/70-urlbar.t ..................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/75-save_url-cookies.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/99-changes.t .................... # Checking for version 0.71 t/99-changes.t .................... ok t/99-examples.t ................... ok t/99-manifest.t ................... ok t/99-pod.t ........................ ok t/99-todo.t ....................... ok t/99-unix-text.t .................. ok t/99-versions.t ................... skipped: File::Slurp needed for te +sting t/mechanize/autocheck.t ........... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/mechanize/content.t ............. skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/rt65615.t ....................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/rt78706.t ....................... "my" variable $result masks earlie +r declaration in same scope at t/rt78706.t line 30. t/rt78706.t ....................... skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 t/select.t ........................ skipped: Couldn't connect to MozRe +pl: command timed-out at /home/user1/perl5/lib/perl5/MozRepl/Client.p +m line 186 All tests successful. Files=84, Tests=97, 870 wallclock secs ( 0.27 usr 0.22 sys + 21.66 cu +sr 22.63 csys = 44.77 CPU) Result: PASS

      Given the above, it appears my perl script is never connecting to mozrepl. As I said previously, I have verified that mozrepl is running and can connect to it using "telnet localhost 4242".

      Does anyone have any ideas?

      I installed www::mechanize::firefox through CPAN, which should automatically run the tests, correct? Based on my admittedly limited experience using CPAN, it won't by default install any module that fails its built in tests.

Re: can't get www::mechanize::firefox to work
by Corion (Patriarch) on Apr 13, 2013 at 18:26 UTC
    Maybe explicitly set the port. It seems weird that WWW::Mechanize::Firefox would fail where telnet works. Maybe $ENV{MOZREPL} is set?

      I added

      $ENV{MOZREPL} = "localhost:4242";

      but that didn't change anything.

        That's weird.

        From the test scripts all skipping, it seems that telnet can connect. So I suggest you consult with your system administrator as to why that would be while Firefox cannot connect from the same machine.