The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Mechanize::Firefox::Troubleshooting - things to watch out for

Installation

If you notice that tests get skipped and/or the module installs but "does not seem to work", there are some more steps required to configure Firefox:

  1. Install mozrepl from

    http://wiki.github.com/bard/mozrepl/

    A direct link is

    http://repo.hyperstruct.net/mozrepl/1.0/mozrepl.xpi

  2. Launch Firefox

  3. Start mozrepl in Firefox by going to the menu:

       "Tools" -> "MozRepl" -> "Start"

    You may want to tick the "Activate on startup" item.

    Alternatively, launch the Firefox binary with the -mozrepl command line switch:

      firefox -mozrepl

    If tests still fail, especially t/50-click.t and 51-mech-submit.t , this might be because you use the NoScript Mozilla extension and have it blocking Javascript for file:// URLs. While this is good, the tests need Javascript enabled.

    Solution:

    1. Open t/50-click.html in Firefox

    2. Allow Javascript for all file:// URLs

    3. Re-run tests

    4. No test should fail

Dialogs that break your application

This section lists things that can (and will) happen which might block your Perl scripts from working properly with Firefox.

Save-As Dialog Displays

If a webserver sends the appropriate headers, Firefox will ask the user where to save a file. This dialog will pop up and stall the Perl application until a user clicks "OK" to confirm where to save the file.

Solution

Find where Firefox pops up the dialog and replace that with a callback to Perl.

Workaround

In many cases, you can instruct Firefox to always save files into the same folder. This may or may not be acceptable. You can directly call ->get or ->save_url and also specify where to save the content by using

  $mech->get( $url, ':content_file' => $tempfile );

or alternatively

  $mech->save_url( $url => $target_filename );

Both of these workarounds require you to know the URL you want to download.

Updates to Firefox Add-Ons

The dialog notification for new versions of Add-Ons is not yet automated. If Firefox pops up this dialog, your application will stall until a human closes this dialog.

Solution

Find where Firefox pops up this dialog and override the display either through a setting or through replacing the Javascript code with the appropriate Perl code.

Workaround

Disable checking for and notification about updated Add-Ons.

Proxy password

If a fresh Firefox process is launched and a proxy is configured, Firefox will ask for the credentials needed for that proxy. The Perl script will stall until a human enters or confirms the credentials.

Solution

Find where Firefox pops up this dialog and override the display with a function that supplies the appropriate credentials directly.

Workaround

There is no workaround.

Known Problems

Page Encoding Versus Perl Encoding

Currently, whatever Firefox delivers as the page content is assumed to be UTF-8. This is likely not the case in some situations, for example with pages encoded in koi-8. There is no real workaround to that. WWW::Mechanize needs to talk to Firefox to get its guess about the encoding and then needs to decode the content according to what Firefox tells it.

AUTHOR

Max Maischein corion@cpan.org

COPYRIGHT

Copyright 2010, Max Maischein.

All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.