• Skip to main content
  • Skip to primary sidebar

Ryan McCormick

Dedicated Dad, Software Engineer and Lover of Coffee

How to Install PhantomJS 2.5 Beta on Ubuntu 14.04, 16.04 LTS

March 19, 2017 by Ryan McCormick Leave a Comment

PhantomJS is a quick, excellent alternative to native browser testing for both e2e testing with selenium and JavaScript unit testing with Karma. The beta version, PhantomJS 2.5 offers support for ES2015 unlike the current stable branch (at the time of writing this article 2.1.x).

Download PhantomJS 2.5 for Ubuntu

At the time of writing this article, the following versions are available:

  • Ubuntu 16.04 LTS (xenial)
  • Ubuntu 14.04 LTS (trusty)
  • MacOS – unsure if works on El-Capitan or Yosemite. Will find a way to verify in the future.

Download the version for your operating system from:
https://bitbucket.org/ariya/phantomjs/downloads/

Add PhantomJS to Your Path

TL;DR Advanced

The PhantomJS binary is located under the bin dir of the extracted archive. If you have a preferred way of adding things to your path, go ahead and add it. If you dont know what that means, you can follow along below.

  1. After adding to your path, verify by running which phantomjs from the command line.
  2. If everything looks good and you see the correct path, add the PHANTOMJS_BIN variable to your environment by typing export PHANTOMJS_BIN=`which phantomjs`
  3. NOTE: Make sure you use the backtick character instead of the single quote mark for the sample above!

Instructions for Adding PhantomJS to Environment

These instructions are based off of the assumption that you downloaded the PhantomJS tarball to your downloads directory.

  1. Open your terminal and make sure you are in your home dir.
  2. Type mkdir ./.phantomjs
  3. Move to your new dir cd .phantomjs
  4. Move your archive into your folder cp ~/Downloads/phantomjs-2.5.0-beta-linux-ubuntu-xenial-x86_64.tar.gz ./ (make sure you reference the correct file, as you are typing the filename, you can try hitting the tab key to autocomplete)
  5. Extract your archive tar -xvzf ./phantomjs-2.5.0-beta-linux-ubuntu-xenial-x86_64.tar.gz
  6. Rename the extracted dir mv phantomjs-2.5.0-beta-ubuntu-xenial phantomjs
  7. Change dir into the extracted phantom dir cd phantomjs
  8. Change dir into the phantom bin dir cd bin
  9. Add executable permissions chmod +x phantomjs
  10. Add to your path echo "PATH=$PATH:`pwd`" >> ~/.bashrc
  11. Close and re-open your terminal or set source: source ~/.bashrc
  12. Test by typing: phantomjs --version (at this point you should see the version. At the time of this post, 2.5.0-development).
    • If you dont get a version, you may need to add execute permissions. Browse back to the bin dir and type chmod +x ./phantomjs and try checking the version again. If you still don’t see a version number type source ~/.bashrc and type which phantomjs (you should see a path to the phantomjs bin folder)
  13. After you have verified that you are showing phantomjs 2.5+, you need to add the PHANTOMJS_BIN variable to override any other global installations. type: echo "export PHANTOMJS_BIN=`which phantomjs`" >> ~/.bashrc
  14. Close and re-open your terminal or type: source ~/.bashrc
  15. Verify PHANTOMJS_BIN var: echo $PHANTOMJS_BIN (you should see the executable path for your phantomjs 2.5).

Related

Filed Under: ES2015, Karma, Linux/Unix Tips, Ubuntu Tagged With: angular 2, es2015, karma, phantomjs, typescript, unit testing

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Recent Posts

  • Force Quit Kill all Chrome Windows MacOS
  • SOLVED: Angular 6 CLI Karma Stuck in Single Run | Karma Stops Running
  • How to Manually Install Java 8 on Ubuntu 18.04 LTS
  • Remove VirtualBox from Ubuntu 16.04 Xenial
  • Clear all Node Modules Folders Recursively Mac/Linux

Recent Comments

  • KKV on Webstorm adding spaces between imports and braces | JavaScript and TypeScript
  • jusopi on Clear all Node Modules Folders Recursively Mac/Linux
  • Qaisar Irfan on Clear all Node Modules Folders Recursively Mac/Linux
  • mustafa on Remove VirtualBox from Ubuntu 16.04 Xenial
  • Pourya on How to Manually Install Java 8 on Ubuntu 18.04 LTS

Archives

  • May 2019
  • May 2018
  • April 2018
  • March 2018
  • January 2018
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • March 2017
  • December 2015
  • November 2015
  • July 2015
  • April 2015
  • February 2015
  • September 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • October 2013
  • August 2013
  • June 2013
  • April 2013
  • March 2013
  • February 2013
  • December 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • May 2012
  • March 2012
  • February 2012
  • December 2011
  • November 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • August 2009
  • July 2009
  • May 2009

Categories

  • Angular
  • Angular 2
  • AngularJS (1x branch)
  • Computer Q&A
  • ES2015
  • Internet Marketing
  • Javascript
  • Job Interviews
  • Job Search
  • Karma
  • Laravel
  • Linux
  • Linux/Unix Tips
  • MacOS
  • Microsoft Access
  • Microsoft Excel
  • Microsoft Outlook
  • Microsoft Word
  • News
  • Node
  • Open Source
  • PHP
  • Protractor
  • Resume Writing
  • Spring Boot
  • SQL
  • Ubuntu
  • VBA
  • VBScript
  • VirtualBox
  • Web Development
  • Windows Tips
  • Wordpress

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2023 · Magazine Pro on Genesis Framework · WordPress · Log in