Setting up Phantom.js on Ubuntu
PhantomJS is a headless (no GUI) browser used for testing and capturing screen shots of web sites. I use it to test JavaScript in Ruby on Rails apps, along with Poltergeist, a driver for Capybara, the library for simulating user interaction with a web application.
-
Go to the PhantomJS download page
-
Download the Linux binary, it will be something like this phantomjs-1.9.2-linux-x86_64.tar.bz2
- un-bzip and untar the archive file.
bunzip2 phantomjs-1.9.2-linux-x86_64.tar.bz2 tar -xvf phantomjs-1.9.2-linux-x86_64.tar
- move the file into the /opt directory
sudo mv phantomjs-1.9.2-linux-x86_64 /opt/phantomjs
-
If you don’t have a
~/bin
directory in your path, now would be a good time to make one and include it in your path. - Link the phantomjs executable to a link in your
~/bin
directory.cd ~/bin ln -s /opt/phantomjs/bin/phantomjs phantomjs
- You’re done! Test out the phantomjs command with
phantomjs --help