Skip to main content

PhantomJS v2 some useful commands

As we already know PhantonJS is a browser with no graphical interface used for the automation of web page interaction.

Here are some command that will help us configure our browser more efficiently according to our needs.

 

--debug=[true|false] 

Prints warning and debug message, the default value is false.
It will help us with possible faults you have, errors of JavasSript, libraries, classes, and much more.

 

--ignore-ssl-errors=[true|false]

Ignore SSL errors, such as expired or self-signed certificate errors, default false.
Very useful if we have problems with certificates with false we can avoid some headaches.

 

--load-images=[true|false]

Load all images online, the default is true.
With false we can avoid loading, not always, unnecessary images.

 

--config=[path]

Specifies a JSON-formatted configuration file.
We can specify different configurations according to our needs.

Example of custom configuration for our environment:

--config=/path/to/config.json
{
  "ignoreSslErrors": true,

  "outputEncoding": "utf8",

  /*Degug*/
  "printDebugMessages":true,

  /*Load images*/
  "autoLoadImages":false,
}

Sources:

http://phantomjs.org/api/command-line.html

 

Training courses

Face-to-face and online training for development and product teams.