INSTALLING WWW::Mechanize::Chrome

Install the chrome executable

WWW::Mechanize::Chrome requires that you have the Chrome browser installed on your system. If Chrome is not installed, please consult Google's instructions for help installing the Chrome browser.

WWW::Mechanize::Chrome will do its best to locate Chrome's executable file on your system. With any luck, it will find the executable you want to use. If WWW::Mechanize::Chrome does not find Chrome on your system or you want to use a different executable, you can use the launch_exe constructor argument to tell WWW::Mechanize::Chrome where to find it. You can alse set the CHROME_BIN environment variable to the absolute path of the executable.

Test the chrome executable

You should verify that Chrome's executable is working properly. On Ubuntu, the executable is typically named chrome-browser and so you can test Chrome's installation with:

chrome-browser --version

and you should see something like Google Chrome 67.0.3396.99 returned.

Note that the command you run will vary based on your operating sytem and possibly the version of Chrome installed.

On a Debian system, for example, the command will most likely be something like:

google-chrome-stable --version or google-chrome-beta --version or google-chrome-unstable --version

On Windows, the executable is named chrome.exe and doesn't output information to the console but you can check that Chrome starts by running:

chrome

in the terminal.

On MacOS, the executable can usually be be found inside the Google Chrome.app package in the /Applications directory and its installation can be tested with something like the following:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version

or, if Chrome is installed for a single user:

/Users/<user_name>/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version

If you are having trouble finding, installing, or running Chrome on your system, please consult the appropriate documentation or a knowledgeable expert.

Chrome versions

Note that the Chrome version numbers do not denote availability of features. Features can still be added to Chrome v62 when Chrome v64 is already out.

If you are serious about automating a website, use a separate copy of Chrome and disable its automatic updates.

Module prerequisites on OSX

Imager::File::PNG

This module relies on Imager for processing screenshots. If you don't need this functionality, you can ignore the Imager and Imager::File::PNG installation and use this module with the system Perl provided by Apple.

The installation of Imager::File::PNG works on OSX using the Homebrew tool and the Perl installable through Homebrew:

    brew install perl-5.28
    brew install libpng
    cpan Imager::File::PNG

I haven't been able to make it work using the system Perl.

RUNNING THE TEST SUITE

The normal test invocation is 'make test'.

If your executable has a different name than chrome-browser or chrome.exe or is not in your path, then set the environment variable CHROME_BIN to the absolute path.

If you have Chrome already running, it must have been started with the <--remote-debugging-port=9222> option to enable access to the developer API. You may want to set up a dedicated and version pinned version of Chrome for your automation.

The test suite is apt to disturb your display when a locally running chrome browser gets animated. On unixish systems you can avoid this kind of disturbance by (1) not running any chrome binary and (2) start a separate display with Xvfb and (3) set the DISPLAY variable accordingly. E.g.:

  Xvfb :121 &
  DISPLAY=:121 CHROME_BIN=/usr/bin/google-chrome-stable make test