PhantomJS – headless webpage testing

PhantomJS (www.phantomjs.org) is a headless WebKit scriptable with JavaScript or CoffeeScript.

PhantomJS is the closest to real browser.

PhantomJS can be used to generate HAR from URL by commandline without requirement of a browser.

Reference Links :

  1. Google Code Page describing the usecases http://code.google.com/p/phantomjs/
  2. Quick Start tutorial page : https://github.com/ariya/phantomjs/wiki/Quick-Start
  3. Build Instructions from Source : http://code.google.com/p/phantomjs/wiki/BuildInstructions
  4. ReadyMade binary files for different OS : http://code.google.com/p/phantomjs/downloads/list
  5. Binary I have tested on RHEL-6 : http://phantomjs.googlecode.com/files/phantomjs-1.6.0-linux-x86_64-dynamic.tar.bz2
  6. Nagios using PhantomJS page loadtime : https://github.com/hggh/phantomjs-nagios 

Example Commandline for generating HAR file from URL

  • bin/phantomjs examples/netsniff.js http://movies.yahoo.com > movies.har

Example Commandline for generating PageLoad time from URL

  • bin/phantomjs examples/loadspeed.js http://movies.yahoo.com
    • Page title is Yahoo! Movies - Upcoming Movies, Trailers and Showtimes
      Loading time 3143 msec

Cons : Flash might not work(!)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: