WWW-Mechanize-PhantomJS

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN


[![Travis Build Status](https://travis-ci.org/Corion/www-mechanize-phantomjs.svg?branch=master)](https://travis-ci.org/Corion/www-mechanize-phantomjs)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/www-mechanize-phantomjs?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/www-mechanize-phantomjs)

# NAME

WWW::Mechanize::PhantomJS - automate the PhantomJS browser

# SYNOPSIS

    use WWW::Mechanize::PhantomJS;
    my $mech = WWW::Mechanize::PhantomJS->new();
    $mech->get('http://google.com');

    $mech->eval_in_page('alert("Hello PhantomJS")');
    my $png= $mech->content_as_png();

## `WWW::Mechanize::PhantomJS->new %options`

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

- **autodie**

    Control whether HTTP errors are fatal.

        autodie => 0, # make HTTP errors non-fatal

    The default is to have HTTP errors fatal,
    as that makes debugging much easier than expecting
    you to actually check the results of every action.

- **port**

    Specify the port where PhantomJS should listen

        port => 8910

- **log**

    Specify the log level of PhantomJS

        log => 'OFF'   # Also INFO, WARN, DEBUG

- **launch\_exe**

    Specify the path to the PhantomJS executable.

    The default is `phantomjs` as found via `$ENV{PATH}`.
    You can also provide this information from the outside
    by setting `$ENV{PHANTOMJS_EXE}`.

- **phantomjs\_arg**

    Additional command line arguments to `phantomjs`.  (phantomjs -h)

        phantomjs_arg => ["--proxy=$ENV{HTTP_PROXY}"]

- **launch\_ghostdriver**

    Filename of the `ghostdriver` Javascript code
    to launch. The default is the file distributed with this module.

        launch_ghostdriver => "devel/my/ghostdriver/main.js",

- **launch\_arg**

    Specify additional parameters to the Ghostdriver script.

        launch_arg => [ "--some-new-parameter=foo" ],

    Some interesting parameters are:

        "--webdriver=$port",
        '--webdriver-logfile=/tmp/webdriver',
        '--webdriver-loglevel=DEBUG',
        '--debug=true',

        note: these set config.xxx values in ghostrdriver/config.js

- **cookie\_file**

    Cookies are not directly persisted. If you pass in a path here,
    that file will be used to store or retrieve cookies.

- **ignore\_ssl\_errors**

    If you want `phantomjs` to ignore SSL errors, pass a true value here.

- **driver**

    A premade [Selenium::Remote::Driver](https://metacpan.org/pod/Selenium%3A%3ARemote%3A%3ADriver) object.

- **report\_js\_errors**

    If set to 1, after each request tests for Javascript errors and warns. Useful
    for testing with `use warnings qw(fatal)`.

## `$mech->phantomjs_version`

    print $mech->phantomjs_version;

Returns the version of the PhantomJS executable that is used.

## `$mech->ghostdriver_version`

    print $mech->ghostdriver_version;

Returns the version of the ghostdriver script that is used.

## `$mech->driver`

    my $selenium= $mech->driver

Access the [Selenium::Driver::Remote](https://metacpan.org/pod/Selenium%3A%3ADriver%3A%3ARemote) instance connecting to PhantomJS.

## `$mech->js_alerts()`



( run in 0.655 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )